consulagent

package module
v0.0.0-...-0751674 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 10 Imported by: 0

README

consul-agent

Helper package for Consul integration

Documentation

Overview

Simple helper package for easy integration with Consul server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrivateIPV4

func GetPrivateIPV4() (net.IP, error)

GetPrivateIPV4 returns private ipv4 for EC2 instance

func PrepareServiceNameEnv

func PrepareServiceNameEnv(name, env string) string

Types

type Agent

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

func NewAgent

func NewAgent(config *Config) (*Agent, error)

func (*Agent) Agent

func (a *Agent) Agent() *consul.Agent

func (*Agent) Catalog

func (a *Agent) Catalog() *consul.Catalog

func (*Agent) Client

func (a *Agent) Client() *consul.Client

func (*Agent) KV

func (a *Agent) KV() *consul.KV

func (*Agent) UpdateTTL

func (a *Agent) UpdateTTL(check CheckFunc)

type CheckFunc

type CheckFunc func() bool

type Config

type Config struct {
	ServiceName   string
	ContainerPort int
	HostPort      int
	TargetPort    int
	Address       string
	TTL           time.Duration
	Env           string
	ConsulAddress string
	AgentPort     int
	BehindProxy   bool
	PassPhrase    string
	FailPhrase    string
	// contains filtered or unexported fields
}

func (*Config) Validate

func (c *Config) Validate() error

type Service

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

func NewService

func NewService(name, path string) *Service

func (*Service) Address

func (s *Service) Address() string

func (*Service) Host

func (s *Service) Host() string

func (*Service) HostString

func (s *Service) HostString(protocol string) string

func (*Service) HostStringWithSuffix

func (s *Service) HostStringWithSuffix(protocol, suffix string) string

func (*Service) Name

func (s *Service) Name() string

func (*Service) Path

func (s *Service) Path() string

func (*Service) Port

func (s *Service) Port() int

func (*Service) Url

func (s *Service) Url() *url.URL

type Services

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

Services list of all registered services

func NewServices

func NewServices(agent *consul.Agent, services ...*Service) (*Services, error)

NewServices returns new instance of Services object

func (*Services) Add

func (s *Services) Add(service *Service) error

Add

func (*Services) Delete

func (s *Services) Delete(name string)

func (*Services) Get

func (s *Services) Get(name string) *Service

Get returns service instance by name

func (*Services) Has

func (s *Services) Has(name string) bool

func (*Services) Parse

func (s *Services) Parse(env string, behindProxy bool) error

func (*Services) Update

func (s *Services) Update(env string, behindProxy bool) error

Jump to

Keyboard shortcuts

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