serviced

package
v0.0.0-...-55c0747 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package serviced NOTES

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GrpcServiceDiscoveryName

func GrpcServiceDiscoveryName(serviceName cc.Name) string

GrpcServiceDiscoveryName grpc dial service discovery target name, protocol rule: Scheme:///ServiceDiscoveryName.

func ServiceDiscoveryName

func ServiceDiscoveryName(serviceName cc.Name) string

ServiceDiscoveryName return the service's register path in etcd.

Types

type Discover

type Discover interface {
	LBRoundRobin() grpc.DialOption
}

Discover defines service discovery related operations.

func NewDiscovery

func NewDiscovery(cfg etcd3.Config) (Discover, error)

NewDiscovery create a service discovery instance.

type DiscoveryOption

type DiscoveryOption struct {
	Name cc.Name
}

DiscoveryOption defines all the service discovery related options.

type HealthInfo

type HealthInfo struct {
	// Health is state flag, it's string not boolean.
	Health string `json:"health"`
}

HealthInfo is etcd health info, e.g. '{"health":"true"}'.

type Service

type Service interface {
	State
	// Register the service
	Register() error
	// Deregister the service
	Deregister() error
}

Service defines all the service and discovery related operations.

func NewService

func NewService(cfg etcd3.Config, opt ServiceOption) (Service, error)

NewService create a service instance.

type ServiceDiscover

type ServiceDiscover interface {
	Service
	Discover
}

ServiceDiscover defines all the service and discovery related operations.

func NewServiceD

func NewServiceD(cfg etcd3.Config, opt ServiceOption) (ServiceDiscover, error)

NewServiceD create a service and discovery instance.

type ServiceOption

type ServiceOption struct {
	Name cc.Name
	IP   string
	Port uint
	// Uid is a service's unique identity.
	Uid string
}

ServiceOption defines a service related options.

func (ServiceOption) Validate

func (so ServiceOption) Validate() error

Validate the service option

type State

type State interface {
	// IsMaster test if this service instance is
	// master or not.
	IsMaster() bool
	// DisableMasterSlave disable/enable this service instance's master-slave check.
	// if disabled, treat this service as a slave instead of checking if it is master from service discovery.
	DisableMasterSlave(disable bool)
	// Healthz etcd health check.
	Healthz() error
}

State defines the service's state related operations.

Jump to

Keyboard shortcuts

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