discovery

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Drivers = [...]string{
	DriverConsul: "consul",
	DriverManual: "manual",
}

Drivers are slice of Service Statuses string representations

View Source
var ErrEmptyOptionalPath = errors.New("optional path is empty")
View Source
var Transports = [...]string{
	TransportHttp:  "http",
	TransportHttps: "https",
	TransportWs:    "ws",
	TransportWss:   "wss",
	TransportGrpc:  "grpc",
}

Transports are slice of Service Statuses string representations

Functions

func AddEndOrRemoveFirstSlashIfNeeded added in v0.7.1

func AddEndOrRemoveFirstSlashIfNeeded(addr string) string

Types

type ConsulDiscovery

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

ConsulDiscovery is a Consul implementation of IServiceDiscovery interface

func (*ConsulDiscovery) Discover

func (d *ConsulDiscovery) Discover(service string) ([]service.IService, error)

Discover and return list of the active blockchain addresses for requested networks

type Creator

Creator is discovery factory function

func ParseDiscoveryDriver

func ParseDiscoveryDriver(driver Driver) (Creator, error)

ParseDiscoveryDriver create new addresses discovery Creator based on given discovery driver

type DiscoveryOpts added in v0.7.1

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

func NewDiscoveryOpts added in v0.7.1

func NewDiscoveryOpts(isPathOptional bool, optionalPath string) *DiscoveryOpts

func NilDiscoveryOptions added in v0.7.1

func NilDiscoveryOptions() *DiscoveryOpts

NilDiscoveryOptions to prevent nil pointers if there are no options

type Driver

type Driver int

Driver represent available Service Statuses

const (
	// DriverConsul is consul-driven service discovery
	DriverConsul Driver = iota

	// DriverManual is "manual" discovery
	// based on given array of addresses address
	DriverManual
)

func DriverFromString

func DriverFromString(s string) Driver

DriverFromString return new Driver enum from given string

func DriverFromStringE

func DriverFromStringE(s string) (Driver, error)

DriverFromStringE return new Driver enum from given string or return an error

func (Driver) String

func (s Driver) String() string

String return Driver enum as a string

type ErrInvalidArgumentsLength

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

ErrInvalidArgumentsLength is error when given arguments length for new discovery is invalid

func (ErrInvalidArgumentsLength) Error

Error is throw error as a string

type ErrServiceNotFound

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

ErrServiceNotFound is error when given service can't be found

func (ErrServiceNotFound) Error

func (e ErrServiceNotFound) Error() string

Error is throw error as a string

type ErrUnsupportedDriver

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

ErrUnsupportedDriver is error when discovery driver is unsupported

func (ErrUnsupportedDriver) Error

func (e ErrUnsupportedDriver) Error() string

Error is throw error as a string

type ErrUnsupportedTransportProtocol added in v0.0.11

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

ErrUnsupportedTransportProtocol is error when transport protocol is unsupported

func (ErrUnsupportedTransportProtocol) Error added in v0.0.11

Error is throw error as a string

type IServiceDiscovery

type IServiceDiscovery interface {
	// Discover service by given name
	Discover(service string) ([]service.IService, error)
}

IServiceDiscovery is interface that provides service Discovery and healthchecks

func NewConsulDiscovery

func NewConsulDiscovery(transport TransportProtocol, opts *DiscoveryOpts, addr ...string) (IServiceDiscovery, error)

NewConsulDiscovery create new Consul-driven service Discovery

func NewManualDiscovery

func NewManualDiscovery(transport TransportProtocol, opts *DiscoveryOpts, addrs ...string) (IServiceDiscovery, error)

NewManualDiscovery create new manual NodesDiscovery with given addresses

type ManualDiscovery

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

ManualDiscovery is "manual" implementation of Near addresses discovery

func (*ManualDiscovery) Discover

func (d *ManualDiscovery) Discover(string) (nodes []service.IService, err error)

Discover is discover and return list of the active blockchain addresses for requested networks

type TransportProtocol added in v0.0.11

type TransportProtocol int

TransportProtocol represent available Transport Protocols for discovery

const (
	TransportHttp TransportProtocol = iota
	TransportHttps
	TransportWs
	TransportWss
	TransportGrpc
	TransportUnsupported
)

func TransportFromString added in v0.0.11

func TransportFromString(s string) TransportProtocol

TransportFromString return new Transport enum from given string

func TransportFromStringE added in v0.0.11

func TransportFromStringE(s string) (TransportProtocol, error)

TransportFromStringE return new Transport enum from given string or return an error

func (TransportProtocol) FormatAddress added in v0.0.11

func (s TransportProtocol) FormatAddress(addr string) string

FormatAddress add protocol prefix to given address

func (TransportProtocol) String added in v0.0.11

func (s TransportProtocol) String() string

String return Transport enum as a string

Jump to

Keyboard shortcuts

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