-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @configcat/developers |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
enable-beta-ecosystems: true | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Rust SDK CI | ||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
push: | ||
branches: [ main ] | ||
paths-ignore: | ||
- '**.md' | ||
pull_request: | ||
branches: [ main ] | ||
paths-ignore: | ||
- '**.md' | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Rust | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
- name: Run tests | ||
run: cargo test | ||
|
||
format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Rust | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: rustfmt | ||
- name: Check format | ||
run: cargo fmt --check | ||
|
||
clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Rust | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: clippy | ||
- name: Check format | ||
run: cargo clippy -- -D warnings | ||
|
||
publish-dry-run: | ||
needs: [test, format, clippy] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Rust | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
- name: Publish dry-run | ||
run: cargo publish --dry-run |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Rust SDK Publish | ||
on: | ||
push: | ||
tags: [ '[0-9]+.[0-9]+.[0-9]+' ] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Publish | ||
run: cargo publish --token ${{ secrets.CRATES_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Mark stale issues | ||
|
||
on: | ||
schedule: | ||
- cron: '0 1 * * *' | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
stale: | ||
uses: configcat/.github/.github/workflows/stale.yml@master | ||
secrets: inherit |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Contributing to the ConfigCat Rust SDK | ||
|
||
ConfigCat SDK is an open source project. Feedback and contribution are welcome. Contributions are made to this repo via Issues and Pull Requests. | ||
|
||
## Submitting bug reports and feature requests | ||
|
||
The ConfigCat SDK team monitors the [issue tracker](https://github.com/configcat/rust-sdk/issues) in the SDK repository. Bug reports and feature requests specific to this SDK should be filed in this issue tracker. The team will respond to all newly filed issues. | ||
|
||
## Submitting pull requests | ||
|
||
We encourage pull requests and other contributions from the community. | ||
- Before submitting pull requests, ensure that all temporary or unintended code is removed. | ||
- Be accompanied by a complete Pull Request template (loaded automatically when a PR is created). | ||
- Add unit or integration tests for fixed or changed functionality. | ||
|
||
When you submit a pull request or otherwise seek to include your change in the repository, you waive all your intellectual property rights, including your copyright and patent claims for the submission. For more details please read the [contribution agreement](https://github.com/configcat/legal/blob/main/contribution-agreement.md). | ||
|
||
In general, we follow the ["fork-and-pull" Git workflow](https://github.com/susam/gitpr) | ||
|
||
1. Fork the repository to your own Github account | ||
2. Clone the project to your machine | ||
3. Create a branch locally with a succinct but descriptive name | ||
4. Commit changes to the branch | ||
5. Following any formatting and testing guidelines specific to this repo | ||
6. Push changes to your fork | ||
7. Open a PR in our repository and follow the PR template so that we can efficiently review the changes. | ||
|
||
## Build instructions | ||
|
||
This ConfigCat SDK builds with `cargo`. | ||
|
||
```bash | ||
cargo build | ||
``` | ||
|
||
## Running tests | ||
|
||
```bash | ||
cargo test | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
name = "configcat" | ||
description = "ConfigCat Rust SDK" | ||
authors = ["ConfigCat"] | ||
homepage = "https://configcat.com" | ||
repository = "https://github.com/configcat/rust-sdk" | ||
documentation = "https://configcat.com/docs/sdk-reference/rust" | ||
keywords = ["configcat", "feature-flag", "feature-toggle"] | ||
license = "MIT" | ||
version = "0.1.0" | ||
edition = "2021" | ||
build = "build.rs" | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
serde_repr = "0.1" | ||
log = { version = "0.4", features = ["kv"] } | ||
chrono = "0.4.38" | ||
thiserror = "1.0" | ||
reqwest = "0.12.4" | ||
futures = "0.3.12" | ||
tokio = { version = "1.17.0", features = ["rt", "sync", "macros"] } | ||
tokio-util = "0.7" | ||
lazy_static = "1.4" | ||
sha1 = "0.10" | ||
base16ct = { version = "0.2", features = ["alloc"] } | ||
|
||
[build-dependencies] | ||
built = "0.7" | ||
|
||
[dev-dependencies] | ||
mockito = "1.2.0" | ||
tokio = { version = "1.17.0", features = ["macros"] } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# rust-sdk | ||
# ConfigCat SDK for Rust | ||
|
||
ConfigCat SDK for Rust provides easy integration for your application to [ConfigCat](https://configcat.com). | ||
|
||
## Polling Modes | ||
The ConfigCat SDK supports 3 different polling mechanisms to acquire the setting values from ConfigCat. After latest setting values are downloaded, they are stored in the internal cache then all requests are served from there. Read more about Polling Modes and how to use them at [ConfigCat Docs](https://configcat.com/docs/sdk-reference/rust). | ||
|
||
## Need help? | ||
https://configcat.com/support | ||
|
||
## Contributing | ||
Contributions are welcome. For more info please read the [Contribution Guideline](CONTRIBUTING.md). | ||
|
||
## About ConfigCat | ||
ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using <a href="https://app.configcat.com" target="_blank">ConfigCat Dashboard</a> even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute. | ||
|
||
ConfigCat is a <a href="https://configcat.com" target="_blank">hosted feature flag service</a>. Manage feature toggles across frontend, backend, mobile, desktop apps. <a href="https://configcat.com" target="_blank">Alternative to LaunchDarkly</a>. Management app + feature flag SDKs. | ||
|
||
- [Official ConfigCat SDKs for other platforms](https://github.com/configcat) | ||
- [Documentation](https://configcat.com/docs) | ||
- [Blog](https://configcat.com/blog) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
built::write_built_file().expect("Failed to acquire build-time information"); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// A cache API used to make custom cache implementations. | ||
pub trait ConfigCache: Sync + Send { | ||
/// Gets the actual value from the cache identified by the given `key`. | ||
fn read(&self, key: &str) -> Option<String>; | ||
|
||
/// Writes the given `value` to the cache by the given `key`. | ||
fn write(&self, key: &str, value: &str); | ||
} | ||
|
||
pub struct EmptyConfigCache {} | ||
|
||
impl EmptyConfigCache { | ||
pub fn new() -> Self { | ||
Check failure on line 13 in src/cache.rs GitHub Actions / test
|
||
Self {} | ||
} | ||
} | ||
|
||
impl ConfigCache for EmptyConfigCache { | ||
fn read(&self, _: &str) -> Option<String> { | ||
None | ||
} | ||
fn write(&self, _: &str, _: &str) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::options::{Options, OptionsBuilder, OptionsError}; | ||
use std::sync::Arc; | ||
|
||
pub struct Client { | ||
Check failure on line 4 in src/client.rs GitHub Actions / test
|
||
options: Arc<Options>, | ||
} | ||
|
||
impl Client { | ||
pub fn from_builder(builder: OptionsBuilder) -> Result<Self, OptionsError> { | ||
Check failure on line 9 in src/client.rs GitHub Actions / test
|
||
let result = builder.build(); | ||
match result { | ||
Ok(opts) => Ok(Client::new(opts)), | ||
Err(err) => Err(err), | ||
} | ||
} | ||
|
||
pub fn new(options: Options) -> Self { | ||
Self { | ||
options: Arc::new(options), | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
include!(concat!(env!("OUT_DIR"), "/built.rs")); | ||
|
||
pub const SDK_KEY_PROXY_PREFIX: &str = "configcat-proxy/"; | ||
Check failure on line 3 in src/constants.rs GitHub Actions / test
|
||
pub const SDK_KEY_PREFIX: &str = "configcat-sdk-1"; | ||
Check failure on line 4 in src/constants.rs GitHub Actions / test
|
||
pub const CONFIG_FILE_NAME: &str = "config_v6.json"; | ||
Check failure on line 5 in src/constants.rs GitHub Actions / test
|
||
pub const SERIALIZATION_FORMAT_VERSION: &str = "v2"; | ||
Check failure on line 6 in src/constants.rs GitHub Actions / test
|
||
pub const SDK_KEY_SECTION_LENGTH: i64 = 22; | ||
Check failure on line 7 in src/constants.rs GitHub Actions / test
|
||
pub const GLOBAL_CDN_URL: &str = "https://cdn-global.configcat.com"; | ||
Check failure on line 8 in src/constants.rs GitHub Actions / test
|
||
pub const EU_CDN_URL: &str = "https://cdn-eu.configcat.com"; | ||
|
||
#[cfg(test)] | ||
pub mod test_constants { | ||
pub const MOCK_PATH: &str = "/configuration-files/key/config_v6.json"; | ||
pub const MOCK_KEY: &str = "key"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|