service

package
v0.0.0-...-b02c517 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultVersion     = "latest"
	DefaultAddress     = ":0"
	DefaultNetwork     = "local"
	DefaultDescription = "A service written with Nebula"
	DefaultHeartbeat   = time.Second * 10
)

Variables

View Source
var DefaultOptions = Options{
	Version:     DefaultVersion,
	Address:     DefaultAddress,
	Network:     DefaultNetwork,
	Description: DefaultDescription,
	Heartbeat:   DefaultHeartbeat,
	Metadata:    metadata.MD{},
	Command:     &cobra.Command{},
	Registry:    registry.Default,
	Transport:   transport.Default,
	Client:      client.Default,
	Server:      server.Default,
}

Functions

This section is empty.

Types

type Option

type Option func(*Options)

func Address

func Address(addr string) Option

func Client

func Client(c client.Client) Option

func Command

func Command(c *cobra.Command) Option

func Description

func Description(s string) Option

func Heartbeat

func Heartbeat(d time.Duration) Option

func Metadata

func Metadata(md metadata.MD) Option

func Network

func Network(name string) Option

func Registry

func Registry(r registry.Registry) Option

func Server

func Server(s server.Server) Option

func TLSConfig

func TLSConfig(c *tls.Config) Option

func Timeout

func Timeout(d time.Duration) Option

func Transport

func Transport(t transport.Transport) Option

func Version

func Version(v string) Option

type Options

type Options struct {
	// Version specifies the service version.
	Version string
	// Address specifies an address to bind.
	Address string
	// Network specifies a network to run in. e.g. local, tunnel or ip:port
	Network string
	// Metadata specifies some metadata.
	Metadata metadata.MD
	// Heartbeat specifies how often to re-register to the registry.
	Heartbeat time.Duration
	// Registry specifies a registry provider.
	Registry registry.Registry
	// Transport specifies a transport provider.
	Transport transport.Transport
	// Client specifies a client to use to make RPC calls.
	Client client.Client
	// Server specifies a server to serve this node.
	Server server.Server
	// Profile specifies a profile to instantiate global interfaces.
	Profile profile.Profile
	// TLSConfig specifies the TLS configuration used by client and server.
	TLSConfig *tls.Config
	// Timeout specifies a time limit for requests made by client.
	Timeout time.Duration
	// Command specifies a cobra command for the service.
	Command *cobra.Command
	// Description specifies a description shown in the command.
	Description string
}

type Service

type Service interface {
	// Name returns the service name.
	Name() string
	// Version returns the service version.
	Version() string
	// Client returns the client.
	Client() client.Client
	// Server returns the server.
	Server() server.Server
	// RunCtx runs the service with a context.
	RunCtx(context.Context) error
	// Run runs the service with the background context.
	Run() error
}

func New

func New(name string, opts ...Option) Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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