Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0nkery committed Jul 20, 2023
1 parent fb92e63 commit 5ef215a
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 134 deletions.
154 changes: 64 additions & 90 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ serde_qs = "0.12"
signal-hook = "0.3"
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
sqlx = { version = "0.6", features = ["offline", "postgres", "macros", "uuid", "chrono", "json", "bigdecimal", "runtime-tokio-native-tls"] }
svc-agent = { version = "0.20", features = ["sqlx", "queue-counter"] }
svc-agent = { version = "0.21", features = ["sqlx", "queue-counter"] }
svc-authn = { version = "0.8", features = ["jose", "sqlx"] }
svc-authz = { version = "0.12" }
svc-error = { version = "0.5", features = ["sqlx", "svc-agent", "svc-authn", "svc-authz", "sentry-extension"] }
svc-utils = { version = "0.7", features = ["authn-extractor", "cors-middleware", "log-middleware"] }
svc-nats-client = "0.5"
svc-events = "0.9"
svc-error = { version = "0.6", features = ["sqlx", "svc-agent", "svc-authn", "svc-authz", "sentry-extension"] }
svc-utils = { version = "0.8", features = ["authn-extractor", "cors-middleware", "log-middleware"] }
svc-nats-client = "0.8"
svc-events = "0.11"
tokio = { version = "1.28", features = ["full"] }
tower = "0.4"
tower-http = { version = "0.4", features = ["trace", "cors"] }
Expand Down
8 changes: 4 additions & 4 deletions src/app/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub trait GlobalContext {
fn metrics(&self) -> Arc<Metrics>;
fn s3_client(&self) -> Option<S3Client>;
fn broker_client(&self) -> &dyn BrokerClient;
fn nats_client(&self) -> Option<&dyn NatsClient>;
fn nats_client(&self) -> Option<Arc<dyn NatsClient>>;

async fn get_conn(&self) -> Result<PoolConnection<Postgres>, AppError> {
self.db()
Expand Down Expand Up @@ -121,8 +121,8 @@ impl GlobalContext for AppContext {
self.broker_client.as_ref()
}

fn nats_client(&self) -> Option<&dyn NatsClient> {
self.nats_client.as_deref()
fn nats_client(&self) -> Option<Arc<dyn NatsClient>> {
self.nats_client.clone()
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ impl<'a, C: GlobalContext> GlobalContext for AppMessageContext<'a, C> {
self.global_context.broker_client()
}

fn nats_client(&self) -> Option<&dyn NatsClient> {
fn nats_client(&self) -> Option<Arc<dyn NatsClient>> {
self.global_context.nats_client()
}
}
Expand Down
Loading

0 comments on commit 5ef215a

Please sign in to comment.