Coder Social home page Coder Social logo

sitegui / feattle-rs Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 1.0 657 KB

Feature toggles for Rust, extensible and with background synchronization and administration UI

License: Apache License 2.0

Rust 87.69% JavaScript 5.75% Handlebars 5.98% CSS 0.39% Shell 0.18%
feature-toggle rust crate

feattle-rs's Introduction

feattle

Crates.io Docs.rs CI Coverage Status

Featture toggles for Rust (called "feattles", for short), extensible and with background synchronization and administration UI.

Features

  • Feature toggles that synchronize automatically with a backing storage
  • Feature toggles can be as simple bool, but can also be lists, maps and arbitrary tpes ( (through the [FeattleValue] trait).
  • Web UI with documentation, change history, validation
  • JSON API to read and set the toggles
  • Modular and extensible: use as much or as little of the bundled features as you want. Want to use a different Web UI? A different storage layer? No problem.

Example

use rusoto_s3::S3Client;
use rusoto_core::Region;
use feattle::*;
use std::sync::Arc;

/// A struct with your feature toggles: you can use primitive types (like `bool`, `i32`, etc),
/// standard collections (like `Vec`, `BTreeSet`, etc) or any arbitrary type that implements
/// the required trait.
feattles! {
    struct MyFeattles {
        /// Is this usage considered cool?
        is_cool: bool = true,
        /// Limit the number of "blings" available.
        /// This will not change the number of "blengs", though!
        max_blings: i32,
        /// List the actions that should not be available
        blocked_actions: Vec<String>,
    }
}

// Store their values and history in AWS' S3
let s3_client = S3Client::new(Region::default());
let persistence = S3::new(s3_client, "my-bucket".to_owned(), "some/s3/prefix/".to_owned());

// Create a new instance
let my_feattles = Arc::new(MyFeattles::new(persistence));

// Poll the storage in the background
BackgroundSync::new(&my_feattles).spawn();

// Start the admin UI with `warp`
let admin_panel = Arc::new(AdminPanel::new(my_feattles.clone(), "Project Panda - DEV".to_owned()));
tokio::spawn(run_warp_server(admin_panel.clone(), ([127, 0, 0, 1], 3030)));

// Or serve the admin panel with `axum`
let router = axum_router(admin_panel);
tokio::spawn(
    axum::Server::bind(&([127, 0, 0, 1], 3031).into()).serve(router.into_make_service()),
);

// Read values (note the use of `*`)
assert_eq!(*my_feattles.is_cool(), true);
assert_eq!(*my_feattles.max_blings(), 0);
assert_eq!(*my_feattles.blocked_actions(), Vec::<String>::new());

You can run a full example locally with: cargo run --example full --features='s3 uuid warp axum'.

With this code, you'll get an Web Admin UI like:

Home Web Admin UI

You can use the UI to edit the current values and see their change history. For example, this is what you can expect when editing an enum:

Edit enum

It also supports complex types with a JSON editor and helpful error diagnostics:

Edit JSON

How it works

The macro will generate a struct with the given name and visibility modifier (assuming private by default). The generated struct implements [Feattles] and also exposes one method for each feattle.

The methods created for each feattle allow reading their current value. For example, for a feattle is_cool: bool, there will be a method like pub fn is_cool(&self) -> MappedRwLockReadGuard<bool>. Note the use of [parking_lot::MappedRwLockReadGuard] because the interior of the struct is stored behind a RwLock to control concurrent access.

A feattle is created with the syntax $key: $type [= $default]. You can use doc coments ( starting with ///) to describe nicely what they do in your system. You can use any type that implements [FeattleValue] and optionally provide a default. If not provided, the default will be created with Default::default().

Minimum supported Rust version

As of this release, the MSRV is 1.60.0, as tested in the CI. A patch release will never require a newer MSRV.

Optional features

You can easily declare feattles with your custom types, use another persistance storage logic or Web Framework (or any at all). For some out-of-the-box functionality, you can activate these cargo features:

  • uuid: will add support for [uuid::Uuid].
  • s3: provides [S3] to integrate with AWS' S3
  • warp: provides [run_warp_server] for a read-to-use integration with [warp]
  • axum: provides [axum_router] for a read-to-use integration with [axum]

Crate's organization

This crate is a simple re-export of these three components:

  • feattle-core: Crates.io
  • feattle-sync: Crates.io
  • feattle-ui: Crates.io

Having them separate allows for leaner lower-level integration. If you're creating a crate to provide a different storage or admin, you just need feattle-core.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md.

feattle-rs's People

Contributors

sitegui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jtojnar

feattle-rs's Issues

RUSTSEC-2022-0071: Rusoto is unmaintained

Rusoto is unmaintained

Details
Status unmaintained
Package rusoto_credential
Version 0.48.0
URL rusoto/rusoto#1651
Date 2022-04-24

The maintainers of Rusoto advise that all its crates are deprecated. This includes the common crates rusoto_core, rusoto_signature, rusoto_credential, and service crates such as rusoto_s3 and rusoto_ec2.

Users should migrate to the AWS SDK for Rust, which is maintained by AWS.

See advisory page for additional details.

RUSTSEC-2020-0071: Potential segfault in the time crate

Potential segfault in the time crate

Details
Package time
Version 0.1.45
URL time-rs/time#293
Date 2020-11-18
Patched versions >=0.2.23
Unaffected versions =0.2.0,=0.2.1,=0.2.2,=0.2.3,=0.2.4,=0.2.5,=0.2.6

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

The affected functions from time 0.2.7 through 0.2.22 are:

  • time::UtcOffset::local_offset_at
  • time::UtcOffset::try_local_offset_at
  • time::UtcOffset::current_local_offset
  • time::UtcOffset::try_current_local_offset
  • time::OffsetDateTime::now_local
  • time::OffsetDateTime::try_now_local

The affected functions in time 0.1 (all versions) are:

  • at
  • at_utc
  • now

Non-Unix targets (including Windows and wasm) are unaffected.

Patches

Pending a proper fix, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods.

Users and library authors with time in their dependency tree should perform cargo update, which will pull in the updated, unaffected code.

Users of time 0.1 do not have a patch and should upgrade to an unaffected version: time 0.2.23 or greater or the 0.3 series.

Workarounds

No workarounds are known.

See advisory page for additional details.

Nice idea of project!

Oi guilherme, bom?

Te pinguei no Telegram, mas aparentemente tu não ta usando e não achei outro contato pra falar contigo haha (malz o flood aqui no repositório). Se der pra passar teu e-mail/telefone no meu e-mail: [email protected]
Queria trocar umas idéias contigo sobre Rust.

Abraços

RUSTSEC-2023-0028: buf_redux is Unmaintained

buf_redux is Unmaintained

Details
Status unmaintained
Package buf_redux
Version 0.8.4
URL https://github.com/abonander/buf_redux/issues
Date 2023-01-24

Last release was over three years ago.

The maintainer(s) have been unreachable to respond to any issues that may or may not include security issues.

The repository is now archived and there is no security policy in place to contact the maintainer(s) otherwise.

The safety-undocumented unsafe in the crate may or may not be safe to use.

The crate also has a current future incompatibility warning buf_redux/23.

Possible Alternatives

The below may or may not provide alternative(s)

See advisory page for additional details.

RUSTSEC-2022-0048: xml-rs is Unmaintained

xml-rs is Unmaintained

Details
Status unmaintained
Package xml-rs
Version 0.8.4
URL https://github.com/netvl/xml-rs/issues
Date 2022-01-26

xml-rs is a XML parser has open issues around parsing including integer
overflows / panics that may or may not be an issue with untrusted data.

Together with these open issues with Unmaintained status xml-rs
may or may not be suited to parse untrusted data.

Alternatives

See advisory page for additional details.

RUSTSEC-2021-0141: dotenv is Unmaintained

dotenv is Unmaintained

Details
Status unmaintained
Package dotenv
Version 0.15.0
URL dotenv-rs/dotenv#74
Date 2021-12-24

dotenv by description is meant to be used in development or testing only.

Using this in production may or may not be advisable.

Alternatives

The below may or may not be feasible alternative(s):

See advisory page for additional details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.