srclient

package
v0.0.0-...-01962dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("404 not found")

Functions

This section is empty.

Types

type BaseClient

type BaseClient struct {
	// contains filtered or unexported fields
}

BaseClient defines schema registry http client

func NewBaseClient

func NewBaseClient(opts ...BaseClientOption) *BaseClient

NewBaseClient creates new HTTP client

func (*BaseClient) CreateSchema

func (c *BaseClient) CreateSchema(ctx context.Context, schema *Schema) (*Schema, error)

func (*BaseClient) DeleteSchemaByVersion

func (c *BaseClient) DeleteSchemaByVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)

func (*BaseClient) DeleteSubject

func (c *BaseClient) DeleteSubject(ctx context.Context, subject string, permanent bool) ([]int, error)

func (*BaseClient) GetLatestSchema

func (c *BaseClient) GetLatestSchema(ctx context.Context, subject string) (*Schema, error)

func (*BaseClient) GetSchemaByID

func (c *BaseClient) GetSchemaByID(ctx context.Context, schemaID int) (*Schema, error)

func (*BaseClient) GetSchemaByVersion

func (c *BaseClient) GetSchemaByVersion(ctx context.Context, subject string, version int) (*Schema, error)

func (*BaseClient) GetSchemaSubjectVersions

func (c *BaseClient) GetSchemaSubjectVersions(ctx context.Context, schemaID int) (map[string]int, error)

func (*BaseClient) GetSubjectVersions

func (c *BaseClient) GetSubjectVersions(ctx context.Context, subject string) ([]int, error)

func (*BaseClient) GetSubjects

func (c *BaseClient) GetSubjects(ctx context.Context) ([]string, error)

GetSubjects method gets list of defined subjects

func (*BaseClient) IsSchemaCompatible

func (c *BaseClient) IsSchemaCompatible(ctx context.Context, schema *Schema) (bool, error)

type BaseClientOption

type BaseClientOption func(*BaseClient)

func WithCredentials

func WithCredentials(username string, password string) BaseClientOption

WithCredentials option sets credentials for client

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) BaseClientOption

WithHTTPClient option sets http client to use for requests

func WithInsecure

func WithInsecure(insecure ...bool) BaseClientOption

WithInsecure overrides default transport and sets insecure skip verify

func WithURL

func WithURL(val interface{}) BaseClientOption

WithURL option sets URL for client

func (BaseClientOption) OptionType

func (BaseClientOption) OptionType()

type CachingClient

type CachingClient struct {
	// contains filtered or unexported fields
}

CachingClient implements schema registry Client with caching capabilities

func NewCachingClient

func NewCachingClient(client Client, opts ...CachingClientOption) *CachingClient

NewCachingClient creates a new client with caching support

func (*CachingClient) CreateSchema

func (c *CachingClient) CreateSchema(ctx context.Context, schema *Schema) (createdSchema *Schema, err error)

func (*CachingClient) DeleteSchemaByVersion

func (c *CachingClient) DeleteSchemaByVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)

func (*CachingClient) DeleteSubject

func (c *CachingClient) DeleteSubject(ctx context.Context, subject string, permanent bool) ([]int, error)

func (*CachingClient) GetLatestSchema

func (c *CachingClient) GetLatestSchema(ctx context.Context, subject string) (schema *Schema, err error)

func (*CachingClient) GetSchemaByID

func (c *CachingClient) GetSchemaByID(ctx context.Context, schemaID int) (schema *Schema, err error)

func (*CachingClient) GetSchemaByVersion

func (c *CachingClient) GetSchemaByVersion(ctx context.Context, subject string, version int) (schema *Schema, err error)

func (*CachingClient) GetSchemaSubjectVersions

func (c *CachingClient) GetSchemaSubjectVersions(ctx context.Context, schemaID int) (map[string]int, error)

func (*CachingClient) GetSubjectVersions

func (c *CachingClient) GetSubjectVersions(ctx context.Context, subject string) (versions []int, err error)

func (*CachingClient) GetSubjects

func (c *CachingClient) GetSubjects(ctx context.Context) (subjects []string, err error)

GetSubjects gets a list of defines subjects

func (*CachingClient) IsSchemaCompatible

func (c *CachingClient) IsSchemaCompatible(ctx context.Context, schema *Schema) (bool, error)

type CachingClientOption

type CachingClientOption func(*CachingClient)

func WithExpiration

func WithExpiration(time time.Duration) CachingClientOption

WithExpiration set expiration for mutable entries like list of subjects

func WithSchemaValueCaching

func WithSchemaValueCaching(enable ...bool) CachingClientOption

WithSchemaValueCaching enables caching of schema values

func (CachingClientOption) OptionType

func (CachingClientOption) OptionType()

type Client

type Client interface {
	GetSubjects(ctx context.Context) ([]string, error)
	GetSubjectVersions(ctx context.Context, subject string) ([]int, error)
	GetSchemaByID(ctx context.Context, schemaID int) (*Schema, error)
	GetSchemaByVersion(ctx context.Context, subject string, version int) (*Schema, error)
	GetSchemaSubjectVersions(ctx context.Context, schemaID int) (map[string]int, error)
	GetLatestSchema(ctx context.Context, subject string) (*Schema, error)
	CreateSchema(ctx context.Context, schema *Schema) (*Schema, error)
	DeleteSubject(ctx context.Context, subject string, permanent bool) ([]int, error)
	DeleteSchemaByVersion(ctx context.Context, subject string, version int, permanent bool) (int, error)
	IsSchemaCompatible(ctx context.Context, schema *Schema) (bool, error)
}

Client defines interface for schema registry client, that is implemented by HTTPClient and CachingClient

func NewClient

func NewClient(opts ...Option) Client

NewClient creates a new Client with optional caching

type GlobalOption

type GlobalOption func(o *globalOptions)

func WithCaching

func WithCaching(enable ...bool) GlobalOption

WithCaching enables client caching

func (GlobalOption) OptionType

func (GlobalOption) OptionType()

type Option

type Option interface{ OptionType() }

Option interface is here, so we can type check if valid arg is parsed as Option to client

type Reference

type Reference struct {
	Name    string `json:"name"`
	Subject string `json:"subject"`
	Version int    `json:"version"`
}

Reference defines struct for schema registry references

In case of protobuf these are imported schema files and in case of JSON schema these are schemas referenced using $ref

type Schema

type Schema struct {
	ID         int         `json:"id,omitempty"`
	Schema     string      `json:"schema,omitempty"`
	Subject    string      `json:"subject,omitempty"`
	Version    int         `json:"version,omitempty"`
	References []Reference `json:"references,omitempty"`
	Type       SchemaType  `json:"schemaType,omitempty"`
}

Schema is a data structure that holds all the relevant information about schemas.

func (*Schema) GetRawSchema

func (s *Schema) GetRawSchema() (rawSchema string)

type SchemaType

type SchemaType string

SchemaType defines type of schema

const (
	// ProtobufSchemaType schema type
	ProtobufSchemaType SchemaType = "PROTOBUF"

	// AvroSchemaType schema type
	AvroSchemaType SchemaType = "AVRO"

	// JSONSchemaType scema type
	JSONSchemaType SchemaType = "JSON"
)

func (SchemaType) String

func (s SchemaType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL