etcd

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BroadcastPath          = "/bus/broadcast"
	QueuePath              = "/bus/queue"
	CacheErrorsPrefix      = "/plumber-server/error-messages"
	CacheConnectionsPrefix = "/plumber-server/connections"
	CacheSchemasPrefix     = "/plumber-server/schemas"
	CacheRelaysPrefix      = "/plumber-server/relay"
	CacheServicesPrefix    = "/plumber-server/services"
	CacheValidationsPrefix = "/plumber-server/validations"
	CacheServerConfigKey   = "/plumber-server/server-config"
	CacheReadsPrefix       = "/plumber-server/reads"
	CacheCompositesPrefix  = "/plumber-server/composites"
)
View Source
const (
	CreateConnection = "CreateConnection"
	UpdateConnection = "UpdateConnection"
	DeleteConnection = "DeleteConnection"

	CreateService = "CreateService"
	UpdateService = "UpdateService"
	DeleteService = "DeleteService"

	CreateSchema = "CreateSchema"
	UpdateSchema = "UpdateSchema"
	DeleteSchema = "DeleteSchema"

	CreateRelay = "CreateRelay"
	UpdateRelay = "UpdateRelay"
	DeleteRelay = "DeleteRelay"

	CreateValidation = "CreateValidation"
	UpdateValidation = "UpdateValidation"
	DeleteValidation = "DeleteValidation"

	CreateRead = "CreateRead"
	DeleteRead = "DeleteRead"

	CreateComposite = "CreateComposite"
	UpdateComposite = "UpdateComposite"
	DeleteComposite = "DeleteComposite"

	UpdateConfig = "UpdateConfig"
)

Variables

View Source
var (
	ServerNotStartedErr     = errors.New("server not started")
	ServerAlreadyStartedErr = errors.New("server already started")
)
View Source
var (
	ErrMissingConfigMessage  = errors.New("msg cannot be nil")
	ErrMissingGithubToken    = errors.New("GithubToken cannot be empty")
	ErrMissingVCServiceToken = errors.New("VCServiceToken cannot be empty")
)

Functions

This section is empty.

Types

type Action

type Action string

type Etcd

type Etcd struct {
	PlumberConfig *config.Config
	// contains filtered or unexported fields
}

func New

func New(serverOptions *opts.ServerOptions, plumberConfig *config.Config) (*Etcd, error)

func (*Etcd) Broadcast

func (e *Etcd) Broadcast(ctx context.Context, msg *Message) error

func (*Etcd) Client

func (e *Etcd) Client() *clientv3.Client

func (*Etcd) Delete

func (e *Etcd) Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)

func (*Etcd) Direct

func (e *Etcd) Direct(ctx context.Context, node string, msg *Message) error

func (*Etcd) Get

func (e *Etcd) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)

func (*Etcd) GrantLease

func (e *Etcd) GrantLease(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error)

func (*Etcd) PopulateCache

func (e *Etcd) PopulateCache() error

PopulateCache loads config from etcd

func (*Etcd) PublishConfigUpdate

func (e *Etcd) PublishConfigUpdate(ctx context.Context, msg *MessageUpdateConfig) error

PublishConfigUpdate publishes a MessageUpdateConfig message, which other plumber instances will receive and update their config with the new token

func (*Etcd) PublishCreateComposite

func (e *Etcd) PublishCreateComposite(ctx context.Context, comp *opts.Composite) error

PublishCreateComposite publishes a CreateComposite message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Etcd) PublishCreateConnection

func (e *Etcd) PublishCreateConnection(ctx context.Context, conn *opts.ConnectionOptions) error

PublishCreateConnection publishes a CreateConnection message, which other plumber instances will receive and add the connection to their local in-memory maps

func (*Etcd) PublishCreateRead

func (e *Etcd) PublishCreateRead(ctx context.Context, read *opts.ReadOptions) error

PublishCreateRead publishes a CreateRead message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Etcd) PublishCreateRelay

func (e *Etcd) PublishCreateRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishCreateRelay publishes a CreateRelay message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Etcd) PublishCreateSchema

func (e *Etcd) PublishCreateSchema(ctx context.Context, schema *protos.Schema) error

PublishCreateSchema publishes a CreateSchema message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Etcd) PublishCreateService

func (e *Etcd) PublishCreateService(ctx context.Context, svc *protos.Service) error

PublishCreateService publishes a CreateService message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Etcd) PublishCreateValidation

func (e *Etcd) PublishCreateValidation(ctx context.Context, validation *common.Validation) error

PublishCreateValidation publishes a CreateValidation message, which other plumber instances will receive and add the service to their local in-memory maps

func (*Etcd) PublishDeleteComposite

func (e *Etcd) PublishDeleteComposite(ctx context.Context, comp *opts.Composite) error

PublishDeleteComposite publishes a DeleteComposite message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishDeleteConnection

func (e *Etcd) PublishDeleteConnection(ctx context.Context, conn *opts.ConnectionOptions) error

PublishDeleteConnection publishes a DeleteConnection message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishDeleteRead

func (e *Etcd) PublishDeleteRead(ctx context.Context, read *opts.ReadOptions) error

PublishDeleteRead publishes a DeleteRead message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishDeleteRelay

func (e *Etcd) PublishDeleteRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishDeleteRelay publishes a DeleteRelay message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishDeleteSchema

func (e *Etcd) PublishDeleteSchema(ctx context.Context, schema *protos.Schema) error

PublishDeleteSchema publishes a DeleteSchema message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishDeleteService

func (e *Etcd) PublishDeleteService(ctx context.Context, svc *protos.Service) error

PublishDeleteService publishes a DeleteService message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishDeleteValidation

func (e *Etcd) PublishDeleteValidation(ctx context.Context, validation *common.Validation) error

PublishDeleteValidation publishes a DeleteValidation message, which other plumber instances will receive and delete from their local in-memory maps

func (*Etcd) PublishUpdateComposite

func (e *Etcd) PublishUpdateComposite(ctx context.Context, comp *opts.Composite) error

PublishUpdateComposite publishes an UpdateComposite message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Etcd) PublishUpdateConnection

func (e *Etcd) PublishUpdateConnection(ctx context.Context, conn *opts.ConnectionOptions) error

PublishUpdateConnection publishes an UpdateConnection message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Etcd) PublishUpdateRelay

func (e *Etcd) PublishUpdateRelay(ctx context.Context, relay *opts.RelayOptions) error

PublishUpdateRelay publishes an UpdateRelay message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Etcd) PublishUpdateSchema

func (e *Etcd) PublishUpdateSchema(ctx context.Context, schema *protos.Schema) error

PublishUpdateSchema publishes an UpdateSchema message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Etcd) PublishUpdateService

func (e *Etcd) PublishUpdateService(ctx context.Context, svc *protos.Service) error

PublishUpdateService publishes an UpdateService message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Etcd) PublishUpdateValidation

func (e *Etcd) PublishUpdateValidation(ctx context.Context, validation *common.Validation) error

PublishUpdateValidation publishes an UpdateValidation message, which other plumber instances will receive and update the connection in their local in-memory maps

func (*Etcd) Put

func (e *Etcd) Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)

func (*Etcd) PutWithTTL

func (e *Etcd) PutWithTTL(ctx context.Context, key, val string, expires time.Duration) (*clientv3.PutResponse, error)

func (*Etcd) SaveConfig

func (e *Etcd) SaveConfig(ctx context.Context, cfg *config.Config) error

SaveConfig marshals a config.Config to JSON and saves it to etcd so that it can be retrieved on startup

func (*Etcd) Shutdown

func (e *Etcd) Shutdown(force bool) error

func (*Etcd) Start

func (e *Etcd) Start(serviceCtx context.Context) error

type HandlerFunc

type HandlerFunc func(context.Context, *clientv3.WatchResponse) error

type IEtcd

type IEtcd interface {
	Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
	GrantLease(ctx context.Context, ttl int64) (*clientv3.LeaseGrantResponse, error)
	Put(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
	PutWithTTL(ctx context.Context, key, val string, expires time.Duration) (*clientv3.PutResponse, error)
	Delete(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)

	Broadcast(ctx context.Context, msg *Message) error
	Direct(ctx context.Context, node string, msg *Message) error
	SaveConfig(ctx context.Context, cfg *config.Config) error
	Shutdown(force bool) error
	Start(serviceCtx context.Context) error

	PublishCreateService(ctx context.Context, svc *protos.Service) error
	PublishUpdateService(ctx context.Context, svc *protos.Service) error
	PublishDeleteService(ctx context.Context, svc *protos.Service) error
	PublishCreateConnection(ctx context.Context, conn *opts.ConnectionOptions) error
	PublishUpdateConnection(ctx context.Context, conn *opts.ConnectionOptions) error
	PublishDeleteConnection(ctx context.Context, conn *opts.ConnectionOptions) error
	PublishCreateSchema(ctx context.Context, schema *protos.Schema) error
	PublishUpdateSchema(ctx context.Context, schema *protos.Schema) error
	PublishDeleteSchema(ctx context.Context, schema *protos.Schema) error
	PublishCreateRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishUpdateRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishDeleteRelay(ctx context.Context, relay *opts.RelayOptions) error
	PublishConfigUpdate(ctx context.Context, msg *MessageUpdateConfig) error
	PublishCreateValidation(ctx context.Context, validation *common.Validation) error
	PublishUpdateValidation(ctx context.Context, validation *common.Validation) error
	PublishDeleteValidation(ctx context.Context, validation *common.Validation) error
	PublishCreateRead(ctx context.Context, svc *opts.ReadOptions) error
	PublishDeleteRead(ctx context.Context, svc *opts.ReadOptions) error
	PublishCreateComposite(ctx context.Context, validation *opts.Composite) error
	PublishUpdateComposite(ctx context.Context, validation *opts.Composite) error
	PublishDeleteComposite(ctx context.Context, validation *opts.Composite) error

	Client() *clientv3.Client
}

type Message

type Message struct {
	Action    Action
	Data      []byte // <- consumer decides what's in here based on action
	Metadata  map[string]string
	EmittedBy string
	EmittedAt time.Time // UTC
}

func (*Message) Validate

func (m *Message) Validate() error

TODO: implement, this isn't being used anywhere at the moment

type MessageUpdateConfig

type MessageUpdateConfig struct {
	VCServiceToken string `json:"vsservice_token"`
	GithubToken    string `json:"oauth_token_github"`
}

MessageUpdateConfig is emitted when a grpc.SetServerOptions() call is made

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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