You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(service): schema mismatch disables service (#198)
* feat: refactor State to hide inner vars, expose functionality via methods
Adds `State::event_db()` which returns an optional handle to the DB connection pool
Adds `State::schema_version_check()` which retuns the result of the schema version check query
Adds `State::is_schema_version_status(svs)` which compares the inner value with the argument
Adds `State::set_schema_version_status(svs)` which sets the inner value with the argument
* feat: add SchemaVersionValidation middleware
Add middleware type to check the State's schema version status variable, if a mismatch
is detected, a `503 Service unavailable` response is returned.
* fix: update GET /health/ready endpoint
* feat: update endpoint to use 'State::event_db()' method
* feat: add SchemaVersionValidation middleware to existing API endpoints
* fix: spelling
// Check if the inner schema version status is set to `Mismatch`,
44
+
// if so, return the `ServiceUnavailable` error, which implements
45
+
// `ResponseError`, with status code `503`.
46
+
// Otherwise, return the endpoint as usual.
47
+
if state.is_schema_version_status(&SchemaVersionStatus::Mismatch){
48
+
returnErr(ServiceUnavailable.into());
49
+
}
50
+
}
51
+
// Calls the endpoint with the request, and returns the response.
52
+
self.ep.call(req).await
53
+
}
54
+
}
55
+
56
+
/// A function that wraps an endpoint with the `SchemaVersionValidation`.
57
+
///
58
+
/// This function is convenient to use with `poem-openapi` [operation parameters](https://docs.rs/poem-openapi/latest/poem_openapi/attr.OpenApi.html#operation-parameters) via the
0 commit comments