Class PayloadSchemaRegistry
The payload schema registry (openspec api-gateway, Payload Schema Registry): a producer registers the schema of every binary payload it emits, and generic readers look a schema up by content type or hash.
public sealed class PayloadSchemaRegistry
- Inheritance
-
PayloadSchemaRegistry
- Inherited Members
Remarks
A schema's bytes are stored raw under their SHA-256 (PayloadSchemaBlobKey(string)), so registering the same schema again writes nothing new. One JSON record (PayloadSchemaCatalogKey) maps each content type to its encoding, message, current hash and earlier hashes; it is written with ETag-guarded operations and retried on a conflict.
Constructors
PayloadSchemaRegistry(IPublicationStateStore, IPayloadSchemaBlobStore)
The payload schema registry (openspec api-gateway, Payload Schema Registry): a producer registers the schema of every binary payload it emits, and generic readers look a schema up by content type or hash.
public PayloadSchemaRegistry(IPublicationStateStore records, IPayloadSchemaBlobStore blobs)
Parameters
recordsIPublicationStateStoreblobsIPayloadSchemaBlobStore
Remarks
A schema's bytes are stored raw under their SHA-256 (PayloadSchemaBlobKey(string)), so registering the same schema again writes nothing new. One JSON record (PayloadSchemaCatalogKey) maps each content type to its encoding, message, current hash and earlier hashes; it is written with ETag-guarded operations and retried on a conflict.
Fields
CatalogWriteAttempts
How often a registration retries the catalog write after a concurrent writer changed it.
public const int CatalogWriteAttempts = 8
Field Value
MaxSchemaBytes
The largest schema accepted: a descriptor set of a payload's files is a few KiB; 1 MiB leaves room for many imports.
public const int MaxSchemaBytes = 1048576
Field Value
Methods
GetAsync(GetPayloadSchemaRequest, CancellationToken)
A schema by content type (its current one) or by hash; null when there is none.
public Task<PayloadSchema?> GetAsync(GetPayloadSchemaRequest request, CancellationToken cancellationToken)
Parameters
requestGetPayloadSchemaRequestcancellationTokenCancellationToken
Returns
- Task<PayloadSchema>
ListAsync(CancellationToken)
Every registered content type, without the schemas' bytes, by content type.
public Task<ListPayloadSchemasResponse> ListAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
- Task<ListPayloadSchemasResponse>
RegisterAsync(PayloadSchema, CancellationToken)
Registers schema; returns its hash and whether the content type's schema changed.
public Task<RegisterPayloadSchemaResponse> RegisterAsync(PayloadSchema schema, CancellationToken cancellationToken)
Parameters
schemaPayloadSchemacancellationTokenCancellationToken
Returns
- Task<RegisterPayloadSchemaResponse>
Exceptions
- InvalidPayloadSchemaException
The schema is malformed or does not name its message.