Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions confidence-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ name = "confidence-shared"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies.confidence]
path = "../confidence"

[lib]
crate-type = ["cdylib"]
name = "confidence_shared"

[dependencies]
tokio = { version = "1.33.0", features = ["rt-multi-thread"] }
async-trait = "0.1.74"
uniffi = {version = "0.27.2", features = ["cli", "tokio"] }
futures = "0.3.29"
lazy_static = "1.4.0"

[profile.release]
debug = false
Expand All @@ -25,8 +27,7 @@ panic = 'abort'

[build-dependencies]
uniffi = {version = "0.27.2", features = ["build"] }
uniffi_macros = "0.27.2"

[[bin]]
# This can be whatever name makes sense for your project, but the rest of this tutorial assumes uniffi-bindgen.
name = "uniffi-bindgen"
path = "src/uniffi-bindgen.rs"
[package.metadata.maturin]
name = "confidence_shared._internal"
12 changes: 12 additions & 0 deletions confidence-shared/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
build-backend = "maturin"

[project]
name = "confidence_shared"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
29 changes: 29 additions & 0 deletions confidence-shared/python/confidence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import uuid
from confidence_shared import *
import asyncio
import time


async def get_flag():
api_config = ApiConfig(api_key="xa0fQ4WKSvuxdjPtesupleiSbZeik6Gf", region=Region.EU)
root = Confidence(api_config)
random_uuid = uuid.uuid4()
uuid_string = str(random_uuid)
confidence = root.with_context({"targeting_key": ConfidenceValue.STRING(uuid_string)})
confidence.track("navigate", {})

value = await confidence.get_flag_string("hawkflag.color", "false")
print(f"Flag value: {value}")


# Another asynchronous function that calls the first one
async def main():
await get_flag()
print("Finished calling say_hello again")
await get_flag()
time.sleep(5)


# Run the main function using asyncio.run (Python 3.7+)
if __name__ == "__main__":
asyncio.run(main())
Loading