Skip to content

Commit 96aeaaf

Browse files
authored
feat: add lifecycle states for config-only resources (#2081)
* feat: add lifecycle status enums and deprecation RPCs to proto definitions Add DataSourceStatus, ConnectionStatus, and RouteStatus enums with ACTIVE/DEPRECATED states. Add DeprecateDataSource, DeprecateConnection, and DeprecateRoute RPCs for config-only resource lifecycle management. * feat: add database migrations for lifecycle status columns Add status (VARCHAR DEFAULT 'ACTIVE') and deprecated_at columns to data_source, provider_connections, and instruction_routes tables with CHECK constraints and tenant-scoped indexes. * feat: implement lifecycle states for market-information DataSource Add ACTIVE/DEPRECATED status to DataSource domain model with Deprecate() method, update persistence layer for status column, and add DeprecateDataSource gRPC handler with idempotent deprecation semantics. * feat: implement lifecycle states for operational-gateway resources Add ACTIVE/DEPRECATED status to ProviderConnection and InstructionRoute domain models with Deprecate() methods. Update persistence entities, repositories, and gRPC handlers with DeprecateConnection and DeprecateRoute endpoints. Update test DDL for new columns. * chore: regenerate frontend TypeScript proto files Update generated TypeScript protobuf files for new lifecycle status enums and deprecation RPCs added to market-information and operational-gateway protos. * fix: add Deprecate method to mock SourceRepository in tests The mock did not implement the new Deprecate interface method, causing golangci-lint typecheck failures. * fix: add DeprecateDataSource to event-router mock MDS client The generated MarketInformationServiceClient interface gained the new DeprecateDataSource RPC method, requiring mock implementations to match. * fix: use domain constants in status parsers to satisfy goconst lint Replace string literals with domain type constants in parseDataSetStatus and parseDataSourceStatus to avoid repeated string occurrences. * fix: add Deprecate to allowed repository method verbs Lifecycle deprecation is a standard operation for config-only resources, alongside Create/Find/Update/Delete. * fix: add status and deprecated_at columns to test schema DDL The market-information test helper schema.sql was missing the new lifecycle columns, causing integration test failures. * fix: add status columns to tenant-specific test schema DDL The createSchemaDataSourceTable function for multi-tenant test schemas was missing the new columns, causing column mismatch when copying data sources from the public schema via SELECT *. * fix: address review feedback - preserve lifecycle fields in builders Critical fixes: - Add deprecated_at to INSERT column list in Save (was missing, causing EXCLUDED.deprecated_at to always be NULL) - Preserve status and deprecated_at in UpdateDataSource and DeactivateDataSource builders (zero-value status violated CHECK constraint) - Add CHECK constraints to operational-gateway test DDL for parity - Add idx_data_source_status to test schema to match production - Update proto comment to document idempotent deprecation behavior * fix: consolidate lifecycle field preservation in UpdateDataSource Use WithDeprecatedAt directly in builder chain instead of conditional block, reducing function size below 60-line threshold. --------- Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent 5be73ec commit 96aeaaf

34 files changed

Lines changed: 3334 additions & 1628 deletions

api/proto/meridian/market_information/v1/market_information.pb.go

Lines changed: 1096 additions & 883 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/proto/meridian/market_information/v1/market_information.proto

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ message MarketPriceObservation {
241241
repeated meridian.quantity.v1.AttributeEntry attributes = 14;
242242
}
243243

244+
// DataSourceStatus defines the lifecycle state of a data source.
245+
enum DataSourceStatus {
246+
// DATA_SOURCE_STATUS_UNSPECIFIED means the status is unknown.
247+
DATA_SOURCE_STATUS_UNSPECIFIED = 0;
248+
// DATA_SOURCE_STATUS_ACTIVE means the data source is available for use.
249+
DATA_SOURCE_STATUS_ACTIVE = 1;
250+
// DATA_SOURCE_STATUS_DEPRECATED means the data source is no longer recommended for new use.
251+
DATA_SOURCE_STATUS_DEPRECATED = 2;
252+
}
253+
244254
// DataSource represents a provider of market data.
245255
message DataSource {
246256
// id is the unique identifier for this data source (UUID).
@@ -270,13 +280,21 @@ message DataSource {
270280
}];
271281

272282
// is_active indicates whether this source can provide new observations.
283+
// Deprecated: Use status field instead. Kept for backward compatibility.
284+
// Set to false when status is DEPRECATED.
273285
bool is_active = 6;
274286

275287
// created_at is when this source was registered.
276288
google.protobuf.Timestamp created_at = 7 [(buf.validate.field).required = true];
277289

278290
// updated_at is when this source was last updated.
279291
google.protobuf.Timestamp updated_at = 8;
292+
293+
// status is the lifecycle state of this data source.
294+
DataSourceStatus status = 9 [(buf.validate.field).enum.defined_only = true];
295+
296+
// deprecated_at is when this data source was deprecated.
297+
google.protobuf.Timestamp deprecated_at = 10;
280298
}
281299

282300
// ========================================
@@ -436,6 +454,18 @@ service MarketInformationService {
436454
};
437455
}
438456

457+
// DeprecateDataSource transitions a data source from ACTIVE to DEPRECATED.
458+
// Sets is_active to false for backward compatibility.
459+
// Returns NOT_FOUND if data source doesn't exist.
460+
// Idempotent: succeeds if the data source is already DEPRECATED.
461+
// Returns FAILED_PRECONDITION only if the stored state is invalid.
462+
rpc DeprecateDataSource(DeprecateDataSourceRequest) returns (DeprecateDataSourceResponse) {
463+
option (google.api.http) = {
464+
post: "/v1/market-information/sources/{code}/deprecate"
465+
body: "*"
466+
};
467+
}
468+
439469
// ListDataSources returns data sources matching the filter criteria.
440470
rpc ListDataSources(ListDataSourcesRequest) returns (ListDataSourcesResponse) {
441471
option (google.api.http) = {
@@ -779,6 +809,22 @@ message DeactivateDataSourceResponse {
779809
DataSource source = 1;
780810
}
781811

812+
// DeprecateDataSourceRequest transitions a data source from ACTIVE to DEPRECATED.
813+
message DeprecateDataSourceRequest {
814+
// code identifies the data source to deprecate.
815+
string code = 1 [(buf.validate.field).string = {
816+
min_len: 1
817+
max_len: 32
818+
pattern: "^[A-Z][A-Z0-9_]*$"
819+
}];
820+
}
821+
822+
// DeprecateDataSourceResponse returns the deprecated data source.
823+
message DeprecateDataSourceResponse {
824+
// source is the deprecated data source with status DEPRECATED.
825+
DataSource source = 1;
826+
}
827+
782828
// ListDataSourcesRequest specifies filtering for listing data sources.
783829
message ListDataSourcesRequest {
784830
// active_only returns only active data sources if true.

api/proto/meridian/market_information/v1/market_information_grpc.pb.go

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)