Skip to content

Commit

Permalink
chore: flatten modules to make simpler; update dependabot file (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps authored Aug 1, 2024
1 parent 4bf3db8 commit 42636f9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 15 deletions.
12 changes: 11 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ updates:
# kodiak `merge.automerge_label`
- "automerge"

- package-ecosystem: npm
directory: "/flipt-client-browser"
schedule:
interval: weekly
open-pull-requests-limit: 5
labels:
- "dependencies"
# kodiak `merge.automerge_label`
- "automerge"

- package-ecosystem: npm
directory: "/flipt-client-node"
schedule:
Expand Down Expand Up @@ -61,7 +71,7 @@ updates:
- "automerge"

- package-ecosystem: "cargo"
directory: "/flipt-client-browser"
directory: "/flipt-engine-wasm"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
Expand Down
1 change: 1 addition & 0 deletions flipt-engine-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ reqwest = { version = "0.12.2", features = ["json", "blocking"] }
tokio = { version = "1.33.0", features = ["full"] }
futures = "0.3"
openssl = { version = "0.10", features = ["vendored"] }
thiserror = "1.0.63"

[dependencies.flipt-evaluation]
path = "../flipt-evaluation"
Expand Down
2 changes: 1 addition & 1 deletion flipt-engine-ffi/examples/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use fliptengine::{
evaluator::Evaluator,
parser::http::{Authentication, HTTPParserBuilder},
http::{Authentication, HTTPParserBuilder},
};
use fliptevaluation::EvaluationRequest;
use std::collections::HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::{Arc, RwLock};
use fliptevaluation::{
batch_evaluation, boolean_evaluation,
error::Error,
models::{flipt, source::Document},
models::{flipt, source},
parser::Parser,
store::{Snapshot, Store},
variant_evaluation, BatchEvaluationResponse, BooleanEvaluationResponse, EvaluationRequest,
Expand All @@ -27,7 +27,7 @@ where
P: Parser + Send,
{
pub fn new_snapshot_evaluator(namespace: &str, parser: P) -> Result<Self, Error> {
let snap = Snapshot::build(namespace, Document::default())?;
let snap = Snapshot::build(namespace, source::Document::default())?;
let mut e = Evaluator::new(namespace, parser, snap);
e.replace_snapshot();
Ok(e)
Expand Down Expand Up @@ -190,7 +190,7 @@ mod tests {
let mut parser = MockParser::new();
parser
.expect_parse()
.returning(|_| Ok(Some(Document::default())));
.returning(|_| Ok(Some(source::Document::default())));
let evaluator =
Evaluator::new_snapshot_evaluator("namespace", parser).expect("expect valid evaluator");

Expand Down Expand Up @@ -242,7 +242,7 @@ mod tests {
let mut parser = MockParser::new();
parser
.expect_parse()
.returning(|_| Ok(Some(Document::default())));
.returning(|_| Ok(Some(source::Document::default())));
let mut evaluator =
Evaluator::new_snapshot_evaluator("namespace", parser).expect("expect valid evaluator");
evaluator.replace_store(Snapshot::empty("other"), None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ impl Parser for HTTPParser {

#[cfg(test)]
mod tests {
use crate::parser::http::Authentication;
use crate::parser::http::HTTPParserBuilder;
use crate::http::Authentication;
use crate::http::HTTPParserBuilder;
use fliptevaluation::parser::Parser;

#[test]
Expand Down
15 changes: 11 additions & 4 deletions flipt-engine-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod evaluator;
pub mod parser;
pub mod http;

use evaluator::Evaluator;
use parser::http::{Authentication, HTTPParser, HTTPParserBuilder};
use http::{Authentication, HTTPParser, HTTPParserBuilder};

use fliptevaluation::error::Error;
use fliptevaluation::models::flipt;
Expand All @@ -18,6 +18,7 @@ use std::collections::HashMap;
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
use std::sync::{Arc, Mutex};
use thiserror::Error;

#[derive(Deserialize)]
struct FFIEvaluationRequest {
Expand All @@ -44,6 +45,12 @@ enum Status {
Failure,
}

#[derive(Error, Debug, Clone)]
enum FFIError {
#[error("error engine null pointer")]
NullPointer,
}

impl<T> From<Result<T, Error>> for FFIResponse<T>
where
T: Serialize,
Expand Down Expand Up @@ -159,9 +166,9 @@ impl Engine {
///
/// This function should not be called unless an Engine is initiated. It provides a helper
/// utility to retrieve an Engine instance for evaluation use.
unsafe fn get_engine<'a>(engine_ptr: *mut c_void) -> Result<&'a mut Engine, Error> {
unsafe fn get_engine<'a>(engine_ptr: *mut c_void) -> Result<&'a mut Engine, FFIError> {
if engine_ptr.is_null() {
Err(Error::NullPointer)
Err(FFIError::NullPointer)
} else {
Ok(unsafe { &mut *(engine_ptr as *mut Engine) })
}
Expand Down
1 change: 0 additions & 1 deletion flipt-engine-ffi/src/parser/mod.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use thiserror::Error;

#[derive(Error, Debug, Clone)]
pub enum Error {
#[error("error engine null pointer")]
NullPointer,
#[error("error parsing json: {0}")]
InvalidJSON(String),
#[error("invalid request: {0}")]
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 42636f9

Please sign in to comment.