service

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPAddr added in v0.5.0

func IPAddr() (net.IP, error)

IPAddr recupera o endereco IP do serviço

Types

type Config

type Config struct {
	DBHost             string `json:"db_host"`
	DBName             string `json:"db_name"`
	DBUser             string `json:"db_user"`
	DBPassword         string `json:"db_password"`
	DBPort             string `json:"db_port"`
	DBSchema           string `json:"db_schema"`
	RedisServer        string `json:"redis_server"`
	HTTPPort           string `json:"http_port"`
	HTTPAddress        string `json:"http_address"`
	FabioAddress       string `json:"fabio_address"`
	TTL                string `json:"ttl"`
	JWTSecret          string `json:"jwt_secret"`
	RefreshTokenSecret string `json:"refresh_token_secret"`
}

Config representa as configurações de que vem do consul

type Service

type Service struct {
	ID             string
	Name           string
	Config         Config
	ConsulAgent    *consul.Agent
	ConsulKV       *consul.KV
	RedisClient    *redis.Client
	SpecificConfig map[string]interface{}
}

Service agrega as configurações de banco de dados (pgsql) e service discovery (consul)

func New

func New(name, configKey string) (*Service, error)

New cria e configura um serviço

func (*Service) GracefullyShutdown added in v0.6.0

func (s *Service) GracefullyShutdown()

GracefullyShutdown faz o desregistramento no consul (não funciona com watcher, não registre)

func (*Service) RegisterService

func (s *Service) RegisterService(healthcheckFunction func() error) error

RegisterService registra o serviço no consul. O parâmetro healthCheckFunction deve ser uma função que retorna um erro se houver falha

Jump to

Keyboard shortcuts

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