Table of Contents

Class PayloadSchemaRegistry

Namespace
Virtufin.Api.Services
Assembly
Virtufin.Api.dll

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

records IPublicationStateStore
blobs IPayloadSchemaBlobStore

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

int

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

int

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

request GetPayloadSchemaRequest
cancellationToken CancellationToken

Returns

Task<PayloadSchema>

ListAsync(CancellationToken)

Every registered content type, without the schemas' bytes, by content type.

public Task<ListPayloadSchemasResponse> ListAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

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

schema PayloadSchema
cancellationToken CancellationToken

Returns

Task<RegisterPayloadSchemaResponse>

Exceptions

InvalidPayloadSchemaException

The schema is malformed or does not name its message.