consul

package
v3.16.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvHasConsulConfig

func EnvHasConsulConfig() bool

EnvHasConsulConfig returns true if there are items in the local environment that have the prefix `CONSUL_`

func NewClient

func NewClient(cfg *api.Config) (*api.Client, error)

NewClient creates a new consul api.Client with the specified config, call NewConfig to complete the configuration by reading the local environment `CONSUL_` variables.

If no environment variables are set, and the passed cfg is nil, returns a client connected to 127.0.0.1:8500

func NewConfig

func NewConfig(cfg *api.Config) (*api.Config, error)

NewConfig creates a new api.Config using environment variables. If an existing config is passed, it will fill in missing configuration using environment variables or defaults if they exists on the local system.

The config mirrors the same environment variables used by the consul CLI as documented here https://www.consul.io/commands

If no environment variables are set, and the passed cfg is nil, returns a default config pointing to 127.0.0.1:8500

func SpawnLock added in v3.15.2

func SpawnLock(ctx context.Context, cfg *LockConfig) (*lock, error)

SpawnLock spawns a goroutine to handle lock life cycle. Blocks until the lock is acquired, or the context is cancelled. Returns a lock that holds the current state of the lock

Types

type HCLogAdapter added in v3.16.0

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

HCLogAdapter implements the hclog interface, and wraps it around a Logrus entry

func NewHCLogAdapter added in v3.16.0

func NewHCLogAdapter(log logrus.FieldLogger, name string) *HCLogAdapter

func (*HCLogAdapter) CreateEntry added in v3.16.0

func (a *HCLogAdapter) CreateEntry(args []interface{}) *logrus.Entry

func (*HCLogAdapter) Debug added in v3.16.0

func (a *HCLogAdapter) Debug(msg string, args ...interface{})

func (*HCLogAdapter) Error added in v3.16.0

func (a *HCLogAdapter) Error(msg string, args ...interface{})

func (*HCLogAdapter) ImpliedArgs added in v3.16.0

func (a *HCLogAdapter) ImpliedArgs() []interface{}

ImpliedArgs returns With key/value pairs

func (*HCLogAdapter) Info added in v3.16.0

func (a *HCLogAdapter) Info(msg string, args ...interface{})

func (*HCLogAdapter) IsDebug added in v3.16.0

func (a *HCLogAdapter) IsDebug() bool

func (*HCLogAdapter) IsError added in v3.16.0

func (a *HCLogAdapter) IsError() bool

func (*HCLogAdapter) IsInfo added in v3.16.0

func (a *HCLogAdapter) IsInfo() bool

func (*HCLogAdapter) IsTrace added in v3.16.0

func (a *HCLogAdapter) IsTrace() bool

func (*HCLogAdapter) IsWarn added in v3.16.0

func (a *HCLogAdapter) IsWarn() bool

func (*HCLogAdapter) Log added in v3.16.0

func (a *HCLogAdapter) Log(level hclog.Level, msg string, args ...interface{})

func (*HCLogAdapter) Name added in v3.16.0

func (a *HCLogAdapter) Name() string

func (*HCLogAdapter) Named added in v3.16.0

func (a *HCLogAdapter) Named(name string) hclog.Logger

func (*HCLogAdapter) ResetNamed added in v3.16.0

func (a *HCLogAdapter) ResetNamed(name string) hclog.Logger

func (*HCLogAdapter) SetLevel added in v3.16.0

func (a *HCLogAdapter) SetLevel(hclog.Level)

func (*HCLogAdapter) StandardLogger added in v3.16.0

func (a *HCLogAdapter) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger

StandardLogger is meant to return a stdlib Logger type which wraps around hclog. It does this by providing an io.Writer and instantiating a new Logger. It then tries to interpret the log level by parsing the message.

Since we are not using `hclog` in a generic way, and I cannot find any calls to this method from go-plugin, we will poorly support this method. Rather than pull in all of hclog writer parsing logic, pass it a Logrus writer, and hardcode the level to INFO.

Apologies to those who find themselves here.

func (*HCLogAdapter) StandardWriter added in v3.16.0

func (a *HCLogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer

func (*HCLogAdapter) Trace added in v3.16.0

func (*HCLogAdapter) Trace(_ string, _ ...interface{})

HCLog has one more level than we do. As such, we will never set trace level.

func (*HCLogAdapter) Warn added in v3.16.0

func (a *HCLogAdapter) Warn(msg string, args ...interface{})

func (*HCLogAdapter) With added in v3.16.0

func (a *HCLogAdapter) With(args ...interface{}) hclog.Logger

type Lock added in v3.15.2

type Lock interface {
	PutValue(ctx context.Context, b []byte) error
	Unlock(b []byte)
	HasLock() bool
}

Lock attempts to get a lock then continues to keep the lock until told to stop

type LockConfig added in v3.15.2

type LockConfig struct {
	Client      *api.Client
	LockOptions *api.LockOptions
	Log         *logrus.Entry
	OnChange    func(bool)
}

type Mock added in v3.15.2

type Mock struct{}

func (*Mock) HasLock added in v3.15.2

func (*Mock) HasLock() bool

func (*Mock) PutValue added in v3.15.2

func (*Mock) PutValue(ctx context.Context, b []byte) error

func (*Mock) Unlock added in v3.15.2

func (*Mock) Unlock(b []byte)

Jump to

Keyboard shortcuts

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