Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial commit for rust evaluator client side #2322

Merged
merged 25 commits into from
Nov 8, 2023

Conversation

yquansah
Copy link
Contributor

@yquansah yquansah commented Nov 1, 2023

Rust engine for client side evaluation.

The idea of this is for clients to embed the Rust implementation and get an evaluation response by providing a namespace_key, flag_key, context, and entity_id.

Copy link
Contributor

github-actions bot commented Nov 1, 2023

Uffizzi Preview deployment-40312 was deleted.

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

❗ No coverage uploaded for pull request base (client-eval@9408ddf). Click here to learn what that means.
The diff coverage is n/a.

@@              Coverage Diff               @@
##             client-eval    #2322   +/-   ##
==============================================
  Coverage               ?   70.79%           
==============================================
  Files                  ?       78           
  Lines                  ?     7462           
  Branches               ?        0           
==============================================
  Hits                   ?     5283           
  Misses                 ?     1878           
  Partials               ?      301           

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookin great just some quick observations while on mobile

.gitignore Outdated Show resolved Hide resolved
client-evaluators/evaluatord/Cargo.toml Outdated Show resolved Hide resolved
@yquansah yquansah changed the base branch from main to client-eval November 6, 2023 16:53
Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple comments, looking great!

@@ -0,0 +1,899 @@
use chrono::{DateTime, Utc};
use snafu::{prelude::*, Whatever};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason of using snafu over anyhow? I know we use anyhow in our flipt-rust lib, might be nice to consolidate on one

actually I know @brettbuddin mentioned we should create proper error types instead for public facing API (still a TODO in the flipt-rust lib) but wondering if we should create our own errors before this goes GA https://fettblog.eu/rust-error-handling/#custom-errors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markphelps @yquansah Yeah, I used anyhow in that library, because it was kind of a sketch, but long-term I think you'll need to move away from it. Here's what anyhow docs say in comparing to thiserror:

Use Anyhow if you don't care what error type your functions return, you just want it to be easy. This is common in application code. Use thiserror if you are a library that wants to design your own dedicated error type(s) so that on failures the caller gets exactly the information that you choose.

The general guideline at that time (could be an outdated perspective) is to use anyhow for applications where users will see errors, but not interrogate them programatically. Libraries might be different, because the error values might be structured information (e.g. nested errors) that needs to be interrogated—in which case use an error crate that supports that attitude.

@@ -0,0 +1,1340 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markphelps Hmmm maybe not. Thank you for the tip!

}

pub fn replace_snapshot(&mut self) {
let _w_lock = self.mtx.write().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do something else instead of panicking if acquiring these locks fail? perhaps this is good for now, but might want to rethink in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markphelps Yeah I tried to remove most of these unwraps as possible. We could probably handle this more gracefully.

client/engine/src/evaluator/mod.rs Outdated Show resolved Hide resolved
client/engine/src/evaluator/mod.rs Outdated Show resolved Hide resolved
@yquansah yquansah marked this pull request as ready for review November 8, 2023 17:07
@yquansah yquansah requested a review from a team as a code owner November 8, 2023 17:07
@yquansah yquansah merged commit f93be7e into client-eval Nov 8, 2023
27 checks passed
@yquansah yquansah deleted the rust-evaluation branch November 8, 2023 17:07
markphelps added a commit that referenced this pull request Nov 21, 2023
* feat: Evaluation snapshot service (#2330)

* chore(wip): gah

* feat(wip): snapshot api

* feat: finish proto server

* chore: fix linter errors

* chore: move

* chore: fix build

* chore: add ability to skip generating sdks

* chore: dont generate interface method

* chore: fix build

* fix: mount api

* chore: add namespace key to resp

* chore: detect boolean flag types

* chore: create own types for evaluation service

* chore: rm spaces

* chore: rename cmp type fields

---------

Co-authored-by: Yoofi Quansah <[email protected]>

* feat: initial commit for rust evaluator client side (#2322)

* feat: initial commit for rust evaluator client side

* chore: rename of entire directory tree

* chore: write tests for all the matches constraints types

* chore: redo gitignore

* chore: format rust code

* chore: use generic instead of parameter impl

* chore: remove println! statement

* feat: support variant attachment as String type Rust

* feat: new engine logic

* chore: fix unwrap by using match instead

* chore: add boolean method to engine and format code

* feat: add request logic for getting document text from configurable upstream Flipt instance

* chore: apply cargo clippy updates

* feat: add three basic functions for allocating engine and retrieving it

* chore: remove TODO

* feat: modify code to adapt to endpoint

* chore: use environment variables to get update interval

* chore: remove unnecessary clone

* chore: add rust workspace

* chore: update enums

* chore: impl default for responses

* chore: make constants

* feat: Add changes for FFI boundaries and example code

---------

Co-authored-by: Mark Phelps <[email protected]>

* chore: engine model refactor (#2356)

* chore: refactor model layout; fix duration bug

* chore: rename get_duration to get_duration_millis

* feat: add boolean exported unsafe FFI function and couple other fixes (#2357)

Co-authored-by: Mark Phelps <[email protected]>

* chore: restructure client eval (#2362)

* feat: add initial commit for Python evaluation client using Rust core (#2358)

* feat: add initial commit for Python evaluation client using Rust core

* chore: fix README linting issue

* feat: move python source code and project under sdk

* chore: clean up Python client README.md and change ENGINE_LIB_PATH meaning

* chore: fix suggestions on PR

* feat: achieve unit test parity with Golang evaluator on Rust core (#2392)

* feat: add integration style tests for evaluation

* feat: add evaluatortest parity with Golang evaluator on Rust core engine

* chore: use mockall as dev dependency and attribute TestParser as only being used during tests

* feat: add initial commit for flipt-client-go evaluation client (#2390)

* feat: add initial commit for flipt-client-go evaluation client

* chore: fix README.md

* chore: README updates based on suggestions

* chore: only support one namespace for Golang client

* chore: add to go.work

* chore: mod tidy

* feat: incorporate error handling from Rust core over FFI to clients (#2400)

* chore: Rm clients in monorepo (#2407)

* chore: rm clients as they are moving to seperate repo

* chore: rm go client sdk

* chore: remove unused bits from .gitignore around Rust and Python and change go.work version back to 1.21

* chore: mod tidy

---------

Co-authored-by: Yoofi Quansah <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants