pulsavro

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-pulsar-avro

A library provides consumer/producer to work with pulsar, avro and schema registry

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeAvroFromBytes added in v0.1.0

func DecodeAvroFromBytes(schema string, payload []byte) (interface{}, error)

DecodeAvroFromBytes convert bytes to interface{} datum

func EncodeAvroToBytes added in v0.1.0

func EncodeAvroToBytes(schema string, datum interface{}) ([]byte, error)

EncodeAvroToBytes convert interface{} datum to bytes

Types

type AvroConsumer added in v0.1.1

type AvroConsumer struct {
	Consumer pulsar.Consumer
	// contains filtered or unexported fields
}

AvroConsumer is a basic consumer to interact with schema registry, avro and pulsar

func NewAvroConsumer

func NewAvroConsumer(client pulsar.Client, consumerOptions pulsar.ConsumerOptions, schemaRegistryUrls []string) (*AvroConsumer, error)

func (*AvroConsumer) Close added in v0.1.1

func (ac *AvroConsumer) Close()

func (*AvroConsumer) DecodeAvroMessage added in v0.1.1

func (ac *AvroConsumer) DecodeAvroMessage(msg pulsar.Message) (interface{}, error)

func (*AvroConsumer) GetSchemaByTopic added in v0.1.1

func (ac *AvroConsumer) GetSchemaByTopic(topic string) (*goavro.Codec, error)

type AvroProducer

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

func NewAvroProducer

func NewAvroProducer(client pulsar.Client, producerOptions pulsar.ProducerOptions, schemaRegistryUrls []string, schema string) (*AvroProducer, error)

NewAvroProducer is a basic producer to interact with schema registry, avro and pulsar

func (*AvroProducer) Close

func (ap *AvroProducer) Close()

func (*AvroProducer) EncodeAvroMessage added in v0.1.0

func (ap *AvroProducer) EncodeAvroMessage(value interface{}) ([]byte, error)

func (*AvroProducer) Send

func (ap *AvroProducer) Send(message *pulsar.ProducerMessage) (pulsar.MessageID, error)

type CachedSchemaRegistryClient

type CachedSchemaRegistryClient struct {
	SchemaRegistryClient *SchemaRegistryClient
	// contains filtered or unexported fields
}

CachedSchemaRegistryClient is a schema registry client that will cache some data to improve performance

func NewCachedSchemaRegistryClient

func NewCachedSchemaRegistryClient(connect []string) *CachedSchemaRegistryClient

func NewCachedSchemaRegistryClientWithRetries

func NewCachedSchemaRegistryClientWithRetries(connect []string, retries int) *CachedSchemaRegistryClient

func (*CachedSchemaRegistryClient) CreateSchemaByTopic

func (client *CachedSchemaRegistryClient) CreateSchemaByTopic(topic string, schema string) error

CreateSchemaByTopic will create a schema for the specified topic

func (*CachedSchemaRegistryClient) GetSchemaCodecByTopic

func (client *CachedSchemaRegistryClient) GetSchemaCodecByTopic(topic string) (*goavro.Codec, error)

GetSchemaCodecByTopic will return and cache the codec with the given topic information

type SchemaRegistryClient

type SchemaRegistryClient struct {
	SchemaRegistryConnect []string
	// contains filtered or unexported fields
}

SchemaRegistryClient is a basic http client to interact with schema registry

func NewSchemaRegistryClient

func NewSchemaRegistryClient(connect []string) *SchemaRegistryClient

NewSchemaRegistryClient creates a client to talk with the schema registry at the connect string By default it will retry failed requests (5XX responses and http errors) len(connect) number of times

func NewSchemaRegistryClientWithRetries

func NewSchemaRegistryClientWithRetries(connect []string, retries int) *SchemaRegistryClient

NewSchemaRegistryClientWithRetries creates an http client with a configurable amount of retries on 5XX responses

func (*SchemaRegistryClient) CreateSchemaByTopic

func (client *SchemaRegistryClient) CreateSchemaByTopic(topic string, schema string) error

CreateSchemaByTopic creates a schema for the specified topic

func (*SchemaRegistryClient) GetSchemaCodecByTopic

func (client *SchemaRegistryClient) GetSchemaCodecByTopic(topic string) (*goavro.Codec, error)

GetSchemaCodecByTopic returns a goavro.Codec by topic

type SchemaRegistryClientInterface

type SchemaRegistryClientInterface interface {
	GetSchemaCodecByTopic(string) (*goavro.Codec, error)
	CreateSchemaByTopic(string, string) error
}

SchemaRegistryClientInterface defines the api for all clients interfacing with schema registry

Jump to

Keyboard shortcuts

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