Documentation ¶
Index ¶
- Variables
- func AddEndOrRemoveFirstSlashIfNeeded(addr string) string
- type ConsulDiscovery
- type Creator
- type DiscoveryOpts
- type Driver
- type ErrInvalidArgumentsLength
- type ErrServiceNotFound
- type ErrUnsupportedDriver
- type ErrUnsupportedTransportProtocol
- type IServiceDiscovery
- type ManualDiscovery
- type TransportProtocol
Constants ¶
This section is empty.
Variables ¶
var Drivers = [...]string{ DriverConsul: "consul", DriverManual: "manual", }
Drivers are slice of Service Statuses string representations
var ErrEmptyOptionalPath = errors.New("optional path is empty")
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
Types ¶
type ConsulDiscovery ¶
type ConsulDiscovery struct {
// contains filtered or unexported fields
}
ConsulDiscovery is a Consul implementation of IServiceDiscovery interface
type Creator ¶
type Creator func(TransportProtocol, *DiscoveryOpts, ...string) (IServiceDiscovery, error)
Creator is discovery factory function
func ParseDiscoveryDriver ¶
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
func DriverFromString ¶
DriverFromString return new Driver enum from given string
func DriverFromStringE ¶
DriverFromStringE return new Driver enum from given string or return an error
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 ¶
func (e ErrInvalidArgumentsLength) Error() string
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
func (e ErrUnsupportedTransportProtocol) Error() string
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
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