Documentation ¶
Index ¶
- func IsSchemaNotFound(err error) bool
- func IsSubjectNotFound(err error) bool
- func IsVersionNotFound(err error) bool
- type Client
- func (c *Client) DeleteLatestSchemaVersion(ctx context.Context, subject string, permanent bool) (int, error)
- func (c *Client) DeleteSchemaVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)
- func (c *Client) DeleteSubject(ctx context.Context, subject string, permanent bool) (versions []int, err error)
- func (c *Client) GetConfig(ctx context.Context, subject string) (*Config, error)
- func (c *Client) GetLatestSchema(ctx context.Context, subject string) (*Schema, error)
- func (c *Client) GetSchemaByID(ctx context.Context, subjectID int) (string, error)
- func (c *Client) GetSchemaBySubjectAndVersion(ctx context.Context, subject string, version int) (*Schema, error)
- func (c *Client) IsRegistered(ctx context.Context, subject string, schema string) (bool, *Schema, error)
- func (c *Client) RegisterNewSchema(ctx context.Context, subject string, avroSchema string) (int, error)
- func (c *Client) SchemaCompatibleWith(ctx context.Context, schema string, subject string, version int) (bool, error)
- func (c *Client) SetGlobalConfig(ctx context.Context, config Config) (*Config, error)
- func (c *Client) SetSubjectConfig(ctx context.Context, subject string, config Config) (*Config, error)
- func (c *Client) Subjects(ctx context.Context) (subjects []string, err error)
- func (c *Client) Versions(ctx context.Context, subject string) (versions []int, err error)
- type ClientMock
- func (c *ClientMock) DeleteLatestSchemaVersion(ctx context.Context, subject string, permanent bool) (int, error)
- func (c *ClientMock) DeleteSchemaVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)
- func (c *ClientMock) DeleteSubject(ctx context.Context, subject string, permanent bool) (versions []int, err error)
- func (c *ClientMock) GetConfig(ctx context.Context, subject string) (*Config, error)
- func (c *ClientMock) GetLatestSchema(ctx context.Context, subject string) (*Schema, error)
- func (c *ClientMock) GetSchemaByID(ctx context.Context, subjectID int) (string, error)
- func (c *ClientMock) GetSchemaBySubjectAndVersion(ctx context.Context, subject string, version int) (*Schema, error)
- func (c *ClientMock) IsRegistered(ctx context.Context, subject string, schema string) (bool, *Schema, error)
- func (c *ClientMock) RegisterNewSchema(ctx context.Context, subject string, avroSchema string) (int, error)
- func (c *ClientMock) SchemaCompatibleWith(ctx context.Context, schema string, subject string, version int) (bool, error)
- func (c *ClientMock) SetGlobalConfig(ctx context.Context, config Config) (*Config, error)
- func (c *ClientMock) Subjects(ctx context.Context) (subjects []string, err error)
- func (c *ClientMock) Versions(ctx context.Context, subject string) (versions []int, err error)
- type Config
- type Option
- type ResourceError
- type Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSchemaNotFound ¶
IsSchemaNotFound checks the returned error to see if it is kind of a schema not found error code.
func IsSubjectNotFound ¶
IsSubjectNotFound checks the returned error to see if it is kind of a subject not found error code.
func IsVersionNotFound ¶
IsVersionNotFound checks the returned error to see if it's related to a version not found.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client used to interact with the registry schema REST API.
func (*Client) DeleteLatestSchemaVersion ¶
func (c *Client) DeleteLatestSchemaVersion(ctx context.Context, subject string, permanent bool) (int, error)
DeleteLatestSchemaVersion remove the latest version of a schema.
See `DeleteLatestSchemaVersion` to retrieve a subject schema by a specific version.
func (*Client) DeleteSchemaVersion ¶
func (c *Client) DeleteSchemaVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)
DeleteSchemaVersion deletes a specific version of the schema registered
under this subject.
This only deletes the version and the schema ID remains intact making it still possible to decode data using the schema ID. This API is recommended to be used only in development environments or under extreme circumstances where-in, its required to delete a previously registered schema for compatibility purposes or re-register previously registered schema.
func (*Client) DeleteSubject ¶
func (c *Client) DeleteSubject(ctx context.Context, subject string, permanent bool) (versions []int, err error)
DeleteSubject deletes the specified subject and its associated compatibility level if registered. It is recommended to use this API only when a topic needs to be recycled or in development environment. Returns the versions of the schema deleted under this subject.
https://docs.confluent.io/current/schema-registry/docs/api.html#delete--subjects-(string-%20subject)
func (*Client) GetConfig ¶
GetConfig returns the configuration (Config type) for global Schema-Registry or a specific subject. When Config returned has "compatibilityLevel" empty, it's using global settings.
https://docs.confluent.io/current/schema-registry/docs/api.html#get--config-(string-%20subject)
func (*Client) GetLatestSchema ¶
GetLatestSchema returns the latest version of a schema. See `GetSchemaAtVersion` to retrieve a subject schema by a specific version.
func (*Client) GetSchemaByID ¶
GetSchemaByID returns the Avro schema string identified by the id.
https://docs.confluent.io/current/schema-registry/docs/api.html#get--schemas-ids-int-%20id
func (*Client) GetSchemaBySubjectAndVersion ¶
func (c *Client) GetSchemaBySubjectAndVersion(ctx context.Context, subject string, version int) (*Schema, error)
GetSchemaBySubjectAndVersion returns the schema for a particular subject and version.
func (*Client) IsRegistered ¶
func (c *Client) IsRegistered(ctx context.Context, subject string, schema string) (bool, *Schema, error)
IsRegistered tells if the given "schema" is registered for this "subject".
https://docs.confluent.io/current/schema-registry/docs/api.html#post--subjects-(string-%20subject)
func (*Client) RegisterNewSchema ¶
func (c *Client) RegisterNewSchema(ctx context.Context, subject string, avroSchema string) (int, error)
RegisterNewSchema registers a schema. The returned identifier should be used to retrieve this schema from the schemas resource and is different from the schema’s version which is associated with that name.
func (*Client) SchemaCompatibleWith ¶
func (c *Client) SchemaCompatibleWith(ctx context.Context, schema string, subject string, version int) (bool, error)
SchemaCompatibleWith test input schema against a particular version of a subject's schema for compatibility.
Note that the compatibility level applied for the check is the configured compatibility level for the subject (http:get:: /config/(string: subject)). If this subject's compatibility level was never changed, then the global compatibility level applies (http:get:: /config).
func (*Client) SetGlobalConfig ¶
func (*Client) SetSubjectConfig ¶ added in v0.3.0
func (*Client) Subjects ¶
Subjects returns a list of the available subjects(schemas).
https://docs.confluent.io/current/schema-registry/docs/api.html#subjects
type ClientMock ¶
ClientMock is a mock implementation of Client.
func (*ClientMock) DeleteLatestSchemaVersion ¶
func (c *ClientMock) DeleteLatestSchemaVersion(ctx context.Context, subject string, permanent bool) (int, error)
DeleteLatestSchemaVersion method mock
func (*ClientMock) DeleteSchemaVersion ¶
func (c *ClientMock) DeleteSchemaVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)
DeleteSchemaVersion method mock
func (*ClientMock) DeleteSubject ¶
func (c *ClientMock) DeleteSubject(ctx context.Context, subject string, permanent bool) (versions []int, err error)
DeleteSubject method mock
func (*ClientMock) GetLatestSchema ¶
GetLatestSchema method mock
func (*ClientMock) GetSchemaByID ¶
GetSchemaByID method mock
func (*ClientMock) GetSchemaBySubjectAndVersion ¶
func (c *ClientMock) GetSchemaBySubjectAndVersion(ctx context.Context, subject string, version int) (*Schema, error)
GetSchemaBySubjectAndVersion method mock
func (*ClientMock) IsRegistered ¶
func (c *ClientMock) IsRegistered(ctx context.Context, subject string, schema string) (bool, *Schema, error)
IsRegistered method mock
func (*ClientMock) RegisterNewSchema ¶
func (c *ClientMock) RegisterNewSchema(ctx context.Context, subject string, avroSchema string) (int, error)
RegisterNewSchema method mock
func (*ClientMock) SchemaCompatibleWith ¶
func (c *ClientMock) SchemaCompatibleWith(ctx context.Context, schema string, subject string, version int) (bool, error)
SchemaCompatibleWith method mock
func (*ClientMock) SetGlobalConfig ¶ added in v0.1.1
SetGlobalConfig method mock.
type Config ¶
type Config struct { // Compatibility mode of subject or global Compatibility string `json:"compatibility"` }
Config describes a subject or globa schema-registry configuration
type Option ¶
type Option func(*Client)
Option function used to apply modifications to the client.
func UsingClient ¶
UsingClient modifies the underline HTTP Client that schema registry is using for contact with the backend server.
func WithBasicAuth ¶
type ResourceError ¶
type ResourceError struct { ErrorCode int `json:"error_code"` Method string `json:"method,omitempty"` URI string `json:"uri,omitempty"` Message string `json:"message,omitempty"` }
ResourceError is being fired from all API calls when an error code is received.
func (ResourceError) Error ¶
func (err ResourceError) Error() string
Error is used to implement the error interface.
type Schema ¶
type Schema struct { // Schema is the Avro schema string. Schema string `json:"schema"` // Subject where the schema is registered for. Subject string `json:"subject"` // Version of the returned schema. Version int `json:"version"` ID int `json:"id,omitempty"` }
Schema describes a schema, look `GetSchema` for more.