migrator

package
v0.0.0-...-35a4376 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConsumerHasUnexpectedConfig = errors.New("consumer has unexpected config")
View Source
var ErrStreamHasUnexpectedConfig = errors.New("stream has unexpected config")

Functions

This section is empty.

Types

type MigrationInfo

type MigrationInfo struct {
	ID        string                           `json:"id"`
	Policy    Policy                           `json:"policy"`
	Streams   []nats.StreamConfig              `json:"streams"`
	Consumers map[string][]nats.ConsumerConfig `json:"consumers"`
}

func (MigrationInfo) MigrationID

func (i MigrationInfo) MigrationID() string

type Migrator

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

func NewMigrator

func NewMigrator(connection *connection.NatsConnection, options ...Option) (*Migrator, error)

func (*Migrator) IsMigrated

func (m *Migrator) IsMigrated(_ context.Context, migrations []pubsub.MigrationInfo) (bool, error)

func (*Migrator) Migrate

func (m *Migrator) Migrate(ctx context.Context, migrations []pubsub.MigrationInfo) error

type Option

type Option func(*Migrator)

func WithCreateKV

func WithCreateKV(replicas int) Option

type Policy

type Policy string
const (
	// Create new streams and consumers if they are not exist. Doesn't change any existing streams and consumers.
	// If some stream or consumer exists and has an unexpected configuration - an error will occur.
	AddOnlyPolicy Policy = "addOnly"
)

Jump to

Keyboard shortcuts

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