Documentation
¶
Overview ¶
Package kafka_schema provides mechanisms for accessing avro schemata stored in Kafka Schemata are addressed by uuid. All other kinds of addressing mechanisms are built on top of this.
Index ¶
- type Alias
- type AliasDTO
- type AliasListDTO
- type AliasMap
- type AliasRepo
- type AliasRequest
- type AliasesDTO
- type Commander
- type LocalRepo
- func (repo LocalRepo) Count() int
- func (repo LocalRepo) Decode(schema uuid.UUID, datum []byte) (interface{}, error)
- func (repo LocalRepo) DecodeVersion(schema NameVersion, datum []byte) (interface{}, error)
- func (repo LocalRepo) Encode(schema uuid.UUID, datum interface{}) ([]byte, error)
- func (repo LocalRepo) EncodeVersion(schema NameVersion, datum interface{}) ([]byte, error)
- func (repo LocalRepo) GetSpecification(schema uuid.UUID) (string, bool)
- func (repo LocalRepo) ListAliases() []Alias
- func (repo LocalRepo) ListSchemata() []uuid.UUID
- func (repo LocalRepo) WaitAliasReady(alias Alias) chan bool
- func (repo LocalRepo) WaitSchemaReady(schema uuid.UUID) chan bool
- func (repo LocalRepo) WaitVersionReady(schema NameVersion) chan bool
- func (repo LocalRepo) WhoIs(alias Alias) (uuid.UUID, bool)
- type NameVersion
- type Repo
- type SchemaDTO
- type SchemaListDTO
- type SchemaMap
- type SchemataDTO
- type UpdateRequest
- type Updater
- type Version
- type VersionedRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alias ¶
type Alias string
Alias is a plain text name for a schema. Aliases are used for plain text addressing of schemata.
type AliasListDTO ¶
AliasListDTO is used by the explorer to encode its response body.
type AliasMap ¶
type AliasMap struct { catchall.ConcurrentObservable Map aliasMapType }
SchemaMap is a KeyObservable map of Aliases to UUIDs
func NewAliasMap ¶
func NewAliasMap() AliasMap
NewAliasMap constructs an empty AliasMap with no observers.
type AliasRepo ¶
type AliasRepo interface { // WhoIs looks up an alias and returns the associated schema's uuid WhoIs(alias Alias) (uuid.UUID, bool) // WaitAliasReady returns a channel that can be used to wait for an alias and the associated schema to become ready. // This works analogous to func Repo.WaitSchemaReady. WaitAliasReady(alias Alias) chan bool // ListAliases returns a slice of all aliases that are currently available. // Note that this may not represent the actual state stored in Kafka, since there // is some lag between the time when an alias change arrives in Kafka and the // time the Repo implementation has consumed the change. ListAliases() []Alias }
AliasRepo provides high-level access to schemata by their aliases
type AliasRequest ¶
AliasRequest sets the given Alias to equal the given UUID.
type AliasesDTO ¶
type AliasesDTO struct {
Aliases []AliasDTO `json:"aliases"`
}
AliasesDTO is used by the explorer to encode its response body.
type Commander ¶
Commander is a KafkaProducer used for writing schema updates into Kafka.
func (Commander) UpdateAlias ¶
type LocalRepo ¶
type LocalRepo struct { Schemata SchemaMap Aliases AliasMap core.TopicRouter }
LocalRepo is a local Kafka consumer that implements the various schema.*Repo interfaces.
func NewLocalRepo ¶
NewLocalRepo constructs a LocalRepo configured for the specified Kafka broker. Note that since the repo is a Consumer, it needs to be started with Run() before it starts consuming.
func (LocalRepo) DecodeVersion ¶
func (repo LocalRepo) DecodeVersion(schema NameVersion, datum []byte) (interface{}, error)
func (LocalRepo) EncodeVersion ¶
func (repo LocalRepo) EncodeVersion(schema NameVersion, datum interface{}) ([]byte, error)
func (LocalRepo) GetSpecification ¶
func (LocalRepo) ListAliases ¶
func (LocalRepo) ListSchemata ¶
func (LocalRepo) WaitAliasReady ¶
func (LocalRepo) WaitSchemaReady ¶
func (LocalRepo) WaitVersionReady ¶
func (repo LocalRepo) WaitVersionReady(schema NameVersion) chan bool
type NameVersion ¶
type NameVersion struct { // Name is the plain text address of the thing. Name string // Version is the version number of the thing. // The version number starts at 0 and increases linearly by 1. Version uint }
NameVersion represents a plain text addressable thing that is linearly versioned.
func NewVersionOrigin ¶
func NewVersionOrigin(alias string) NameVersion
func VersionFromAlias ¶
func VersionFromAlias(a Alias) (NameVersion, error)
VersionFromAlias unmarshals a Version from Alias.
func VersionFromString ¶
func VersionFromString(s string) (NameVersion, error)
VersionFromString unmarshals a Version from string. The format is {NAME}-v{VERSION}.
func (NameVersion) Alias ¶
func (v NameVersion) Alias() Alias
func (NameVersion) GetName ¶
func (v NameVersion) GetName() string
func (NameVersion) GetNext ¶
func (v NameVersion) GetNext() (Version, bool)
func (NameVersion) GetPrevious ¶
func (v NameVersion) GetPrevious() (Version, bool)
func (NameVersion) GetVersion ¶
func (v NameVersion) GetVersion() uint
func (NameVersion) IsOrigin ¶
func (v NameVersion) IsOrigin() bool
func (NameVersion) String ¶
func (v NameVersion) String() string
type Repo ¶
type Repo interface { // Decode decodes a datum with the given avro schema Decode(schema uuid.UUID, datum []byte) (interface{}, error) // Encode encodes a datum with the given avro schema Encode(schema uuid.UUID, datum interface{}) ([]byte, error) // WaitSchemaReady returns a channel that can be used to wait for a schema to become available. // Since the schemata are stored in Kafka, it might take the underlying implementation // a while until it has consumed all schema changes. WaitSchemaReady(schema uuid.UUID) chan bool // ListSchemata returns a slice of all uuids that are currently available. // Note that this may not represent the actual state stored in Kafka, since there // is some lag between the time when a schema change arrives in Kafka and the // time the Repo implementation has consumed the change. ListSchemata() []uuid.UUID // GetSpecification returns the avro specification for the given uuid in plain text. GetSpecification(schema uuid.UUID) (specification string, ok bool) // Count returns the number of schemata currently available Count() int }
Repo provides high-level access to Schemata by their uuid
type SchemaListDTO ¶
SchemaListDTO is used by the explorer to encode its response body.
type SchemaMap ¶
type SchemaMap struct { catchall.ConcurrentObservable Map schemaMapType }
SchemaMap is a KeyObservable map of UUIDs to Avro codecs
func NewSchemaMap ¶
func NewSchemaMap() SchemaMap
NewSchemaMap constructs an empty SchemaMap with no observers.
type SchemataDTO ¶
type SchemataDTO struct {
Schemata []SchemaDTO `json:"schemata"`
}
SchemataDTO is used by the explorer to encode its response body.
type UpdateRequest ¶
UpdateRequest sets the given UUID to equal the given plain-text Avro spec.
type Updater ¶
type Updater interface { // UpdateSchema sets the given UUID to equal the given plain-text Avro spec. UpdateSchema(schemaUUID uuid.UUID, specification string) error // UpdateAlias sets the given Alias to equal the given UUID. UpdateAlias(alias string, schemaUUID uuid.UUID) error }
Updater encapsulates the methods required to update the schema repository stored in Kafka.
func NewUpdater ¶
NewUpdater constructs an Updater that uses the given Kafka broker to write updates. This will create a new KafkaProducer.
func NewUpdaterWithProducer ¶
NewUpdater constructs an Updater that uses the given KafkaProducer to produce its events. In most cases, it is fine to use NewUpdater instead and let it create a new KafkaProducer.
type Version ¶
type Version interface { // IsOrigin indicates whether this is the first version of the thing. IsOrigin() bool // GetVersion returns the version number of the thing. GetVersion() uint // GetName returns the name i.e. the plain text address of the thing. GetName() string // GetPrevious returns the Version preceding this Version. // If this is the origin, it returns the origin unchanged. // The ok flag indicates whether the returned Version differs from the passed Version. GetPrevious() (v Version, ok bool) // GetNext returns the Version succeeding this Version. // If this is the most recent Version, it returns the Version unchanged. // The ok flag indicates whether the returned Version differs from the passed Version. GetNext() (v Version, ok bool) // String marshals the Version into a string. String() string // Alias marshals the Version into an Alias. Alias() Alias }
Version provides a high-level interface for versioning operations on a plain-text addressable versioned thing.
type VersionedRepo ¶
type VersionedRepo interface { // DecodeVersion decodes a datum using the specified schema at the specified version. DecodeVersion(schema NameVersion, datum []byte) (interface{}, error) // EncodeVersion encodes a datum using the specified schema at the specified version. EncodeVersion(schema NameVersion, datum interface{}) ([]byte, error) // WaitVersionReady returns a channel that can be used to wait for a schema to become available in the specified version. // This works analogous to func Repo.WaitSchemaReady. WaitVersionReady(schema NameVersion) chan bool }
VersionedRepo provides high-level access to schemata by a using a versioning scheme.