consul

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package consul is registered as a service using consul.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(consulAddr string, id string, instanceName string, instanceEndpoints []string) (registry.Registry, *registry.ServiceInstance, error)

NewRegistry instantiating the consul registry

Types

type Client

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

Client is consul client config

func NewClient

func NewClient(cli *api.Client) *Client

NewClient creates consul client

func (*Client) Deregister

func (d *Client) Deregister(_ context.Context, serviceID string) error

Deregister deregister service by service ID

func (*Client) Register

func (d *Client) Register(_ context.Context, svc *registry.ServiceInstance, enableHealthCheck bool) error

Register register service instance to consul

func (*Client) Service

func (d *Client) Service(ctx context.Context, service string, index uint64, passingOnly bool) ([]*registry.ServiceInstance, uint64, error)

Service get services from consul

type Config

type Config struct {
	*api.Config
}

Config is consul registry config

type Option

type Option func(*Registry)

Option is consul registry option.

func WithHealthCheck

func WithHealthCheck(enable bool) Option

WithHealthCheck with registry health check option.

type Registry

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

Registry is consul registry

func New

func New(apiClient *api.Client, opts ...Option) *Registry

New create a consul registry

func (*Registry) Deregister

func (r *Registry) Deregister(ctx context.Context, svc *registry.ServiceInstance) error

Deregister deregister service

func (*Registry) GetService

func (r *Registry) GetService(_ context.Context, name string) (services []*registry.ServiceInstance, err error)

GetService return service by name

func (*Registry) ListServices

func (r *Registry) ListServices() (allServices map[string][]*registry.ServiceInstance, err error)

ListServices return service list.

func (*Registry) Register

func (r *Registry) Register(ctx context.Context, svc *registry.ServiceInstance) error

Register register service

func (*Registry) Watch

func (r *Registry) Watch(_ context.Context, name string) (registry.Watcher, error)

Watch resolve service by name

Jump to

Keyboard shortcuts

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