server

package
v0.0.0-...-ad68a05 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultAddress default addr
	DefaultAddress = ":0"
	// DefaultName default name
	DefaultName = "go.micro.server"
	// DefaultVersion version
	DefaultVersion = "latest"
	// DefaultID node of id
	DefaultID = uuid.New().String()
	// DefaultNamingServer ...
	// DefaultNamingServer Server = newNamingServer()
	// DefaultRegisterInterval ...
	DefaultRegisterInterval = time.Second * 30
	// DefaultRegisterTTL ...
	DefaultRegisterTTL = time.Minute

	// NewServer creates a new server
	NewServer func(...Option) Server = newNamingServer
)

Functions

func NewNamingResolver

func NewNamingResolver(opts ...Option) *namingResolver

NewNamingResolver new one

Types

type Option

type Option func(*Options)

Option option list

func Name

func Name(n string) Option

Name Server name

func RegisterInterval

func RegisterInterval(t time.Duration) Option

RegisterInterval Register the service with at interval

func RegisterTTL

func RegisterTTL(t time.Duration) Option

RegisterTTL Register the service with a TTL

func WithRegistryNaming

func WithRegistryNaming(reg registry.RegNaming) Option

WithRegistryNaming 注册naming 服务发现

type Options

type Options struct {
	Name    string
	Address string
	// Advertise string
	ID      string
	Version string

	// registry
	// The register expiry time
	RegisterTTL time.Duration
	// The interval on which to register
	RegisterInterval time.Duration

	Registry *registry.Registry

	Server   *grpc.Server
	Listener net.Listener
}

Options is a simple micro server abstraction

type Server

type Server interface {
	Options() Options
	Init(...Option) error
	Start() error
	Stop() error
	String() string
	GetServer() *grpc.Server
	GetListener() net.Listener
	SetListener(net.Listener) bool
	SetAddress(add string)
	GetAddress() string
}

Server is a simple micro server abstraction

Jump to

Keyboard shortcuts

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