consul

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConsulConfigLoad returned when env config for consul results in an error
	ErrConsulConfigLoad = errors.New("error loading consul config")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ServiceName string `env:"SERVICE_NAME"`
	Host        string `env:"CONSUL_HOST,default=localhost"`
	Port        int    `env:"CONSUL_PORT,default=8500"`
	TTL         int    `env:"CONSUL_TTL,default=15"`
}

Config - consul configuration

func NewConfig

func NewConfig() *Config

NewConfig returns the parsed config for jetstream from env

func (*Config) UnmarshalEnv

func (c *Config) UnmarshalEnv(es env.EnvSet) error

UnmarshalEnv env.EnvSet to GatewayConfig

type Consul

type Consul struct {
	*Config
	// contains filtered or unexported fields
}

Consul registry

func NewConsul

func NewConsul() *Consul

NewConsul returns a new consul registry

func (*Consul) Address

func (c *Consul) Address() string

Address returns the prepared consul address

func (*Consul) ConnectionString

func (c *Consul) ConnectionString(args ...interface{}) string

ConnectionString returns the formatted connection string using the config loaded

func (*Consul) HasInitializer

func (c *Consul) HasInitializer() bool

func (*Consul) Initializer

func (c *Consul) Initializer() component.Initializer

func (*Consul) Register

func (c *Consul) Register(
	ctx context.Context,
	server server.Server,
) error

Register registers service with the registry.

func (*Consul) ToString

func (c *Consul) ToString() string

ToString returns the string name of the service registry

type Initializer

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

func NewInitializer

func NewInitializer(c *Consul) *Initializer

NewInitializer returns a new JetStream Initialiazer

func (*Initializer) AddDependency

func (i *Initializer) AddDependency(dep interface{}) error

AddDependency adds necessary service components as dependencies

func (*Initializer) CanRun

func (i *Initializer) CanRun() bool

CanRun returns true if the component has anything to Run

func (*Initializer) CanStop

func (i *Initializer) CanStop() bool

CanRun returns true if the component has anything to Run

func (*Initializer) Dependencies

func (i *Initializer) Dependencies() []string

Dependencies returns the string names of service components that are required as dependencies for this component

func (*Initializer) Run

func (i *Initializer) Run(ctx context.Context) error

Run start the service component

func (*Initializer) Stop

func (i *Initializer) Stop(ctx context.Context) error

Stop - stops the running

Jump to

Keyboard shortcuts

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