srv

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GRPC = iota
	GIN
)

server type list

Variables

View Source
var (
	// DefaultRegistry -
	DefaultRegistry = newRegistry()
	// DefaultRegistryTTL - default
	DefaultRegistryTTL = 30 * time.Second
)
View Source
var (
	// DefaultServer -
	DefaultServer = newRPCServer()
	// DefaultHost -
	DefaultHost = newHost()
	// DefaultPort -
	DefaultPort = "0"
	// DefaultHook -
	DefaultHook = func() {}
)
View Source
var ServerType int

ServerType -

Functions

func NewTags added in v1.1.0

func NewTags(opts *Options) []string

NewTags -

Types

type Option added in v0.8.2

type Option func(*Options)

Option -

func AfterStart added in v0.8.3

func AfterStart(fn func()) Option

AfterStart -

func AfterStop added in v0.8.3

func AfterStop(fn func()) Option

AfterStop -

func BeforeStart added in v0.8.3

func BeforeStart(fn func()) Option

BeforeStart -

func BeforeStop added in v0.8.3

func BeforeStop(fn func()) Option

BeforeStop -

func SetHost added in v0.8.3

func SetHost(host string) Option

SetHost -

func SetName added in v0.8.3

func SetName(n string) Option

SetName of the service

func SetPort added in v0.8.3

func SetPort(port string) Option

SetPort -

func SetRegistry added in v0.8.3

func SetRegistry(r *api.Client) Option

SetRegistry -

func SetRegistryTTL added in v0.8.3

func SetRegistryTTL(t time.Duration) Option

SetRegistryTTL -

func SetServer added in v0.8.3

func SetServer(s http.Handler) Option

SetServer -

func SetVersion added in v0.8.3

func SetVersion(v string) Option

SetVersion of the service

type Options

type Options struct {
	Server   http.Handler
	Host     string
	Port     string
	Listener net.Listener
	// Registry Client
	Registry *api.Client
	// Registry TTL
	RegistryTTL time.Duration

	// Before and After funcs
	BeforeStart func()
	BeforeStop  func()
	AfterStart  func()
	AfterStop   func()
	// contains filtered or unexported fields
}

Options -

type Resolver

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

Resolver implements the gRPC Resolver interface using a Consul backend.

func NewResolver

func NewResolver(client *api.Client, service, tag string) (*Resolver, error)

NewResolver initializes and returns a new Resolver.

func (*Resolver) Close

func (r *Resolver) Close()

Close closes the watcher.

func (*Resolver) Next

func (r *Resolver) Next() ([]*naming.Update, error)

Next -

func (*Resolver) Resolve

func (r *Resolver) Resolve(target string) (naming.Watcher, error)

by Resolver as well, see Next and Close.

type Service

type Service interface {
	// The service id
	ID() string
	// The service name
	Name() string
	// Initialize
	Init(...Option)
	// Version
	Version() string
	// Run the service
	Run() error
	// Options returns the current options
	Options() Options
	// The server
	Server() http.Handler
	// The server type
	ServerType() string
}

Service -

func NewService

func NewService(opts ...Option) Service

NewService - creates and returns a new Service

Jump to

Keyboard shortcuts

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