Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) CreateSchema(ctx context.Context, subject string, schema sr.Schema) (sr.SubjectSchema, error)
- func (c *Client) SchemaByID(ctx context.Context, id int) (sr.Schema, error)
- func (c *Client) SchemaBySubjectVersion(ctx context.Context, subject string, version int) (sr.SubjectSchema, error)
- type Decoder
- type DownloadSchemaStrategy
- type Encoder
- type ExtractAndUploadSchemaStrategy
- type Schema
- type SchemaFactory
- type SchemaStrategy
Constants ¶
This section is empty.
Variables ¶
var DefaultSchemaFactories = map[sr.SchemaType]SchemaFactory{ avro.Type: { Parse: func(s string) (Schema, error) { return avro.Parse(s) }, SchemaForType: func(v any) (Schema, error) { return avro.SchemaForType(v) }, }, }
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a schema registry client that caches schemas. It is safe for concurrent use.
func NewClient ¶
NewClient creates a new client using the provided logger and schema registry client options.
func (*Client) CreateSchema ¶
func (c *Client) CreateSchema(ctx context.Context, subject string, schema sr.Schema) (sr.SubjectSchema, error)
CreateSchema checks if the schema is already registered in the cache and returns the associated sr.SubjectSchema if it is found. Otherwise, the schema is sent to the schema registry and stored in the cache, if the registration was successful.
func (*Client) SchemaByID ¶
SchemaByID checks if the schema is already registered in the cache and returns the associated sr.Schema if it is found. Otherwise, the schema is retrieved from the schema registry and stored in the cache. Note that the returned schema does not contain a subject and version, so the cache will not have an effect on methods that return a sr.SubjectSchema.
func (*Client) SchemaBySubjectVersion ¶
func (c *Client) SchemaBySubjectVersion(ctx context.Context, subject string, version int) (sr.SubjectSchema, error)
SchemaBySubjectVersion checks if the schema is already registered in the cache and returns the associated sr.SubjectSchema if it is found. Otherwise, the schema is retrieved from the schema registry and stored in the cache.
type DownloadSchemaStrategy ¶
type DownloadSchemaStrategy struct { Subject string // TODO add support for specifying "latest" - https://github.com/ConduitIO/conduit/issues/1095 Version int }
func (DownloadSchemaStrategy) GetSchema ¶
func (str DownloadSchemaStrategy) GetSchema(ctx context.Context, client *Client, _ log.CtxLogger, _ record.StructuredData) (Schema, sr.SubjectSchema, error)
type Encoder ¶
type Encoder struct { SchemaStrategy // contains filtered or unexported fields }
func NewEncoder ¶
type ExtractAndUploadSchemaStrategy ¶
type ExtractAndUploadSchemaStrategy struct { Type sr.SchemaType Subject string }
func (ExtractAndUploadSchemaStrategy) GetSchema ¶
func (str ExtractAndUploadSchemaStrategy) GetSchema(ctx context.Context, client *Client, _ log.CtxLogger, sd record.StructuredData) (Schema, sr.SubjectSchema, error)
type Schema ¶
type Schema interface { // Marshal returns the encoded representation of v. Marshal(v any) ([]byte, error) // Unmarshal parses encoded data and stores the result in the value pointed // to by v. If v is nil or not a pointer, Unmarshal returns an error. Unmarshal(b []byte, v any) error // String returns the textual representation of the schema. String() string }