cmd

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 30 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCmd = newCmd()

	DefaultBrokers = map[string]func(...broker.Option) broker.Broker{
		"memory": memory.NewBroker,
		"http":   brokerHttp.NewBroker,
	}

	DefaultClients = map[string]func(...client.Option) client.Client{
		"grpc": cGrpc.NewClient,
	}

	DefaultRegistries = map[string]func(...registry.Option) registry.Registry{
		"mdns":   mdns.NewRegistry,
		"memory": regMemory.NewRegistry,
	}

	DefaultSelectors = map[string]func(...selector.Option) selector.Selector{
		"dns":    dns.NewSelector,
		"static": static.NewSelector,
	}

	DefaultServers = map[string]func(...server.Option) server.Server{
		"grpc": sgrpc.NewServer,
	}

	DefaultCaches = map[string]func(...cache.Option) cache.Cache{
		"memory": memCache.NewCache,
		"noop":   nopCache.NewCache,
	}

	DefaultTracers = map[string]func(...trace.Option) trace.Tracer{
		"memory": memTracer.NewTracer,
	}

	DefaultConfigs = map[string]func(...config.Option) config.Config{
		"memory": configMemory.NewConfig,
	}
)

Functions

func App

func App() *cobra.Command

func Init

func Init(opts ...Option) error

Types

type Cmd

type Cmd interface {
	// App The cobra Command within this cmd
	App() *cobra.Command
	// Init Adds options, parses flags and initialise
	// exits on error
	Init(opts ...Option) error
	// Options set within this command
	Options() Options
}

func NewCmd

func NewCmd(opts ...Option) Cmd

type Option

type Option func(o *Options)

func Broker

func Broker(b *broker.Broker) Option

func Cache

func Cache(c *cache.Cache) Option

func Client

func Client(c *client.Client) Option

func Command added in v1.4.20

func Command(app *cobra.Command) Option

func Config

func Config(c *config.Config) Option

func Description

func Description(d string) Option

Description command line Description

func Name

func Name(n string) Option

Name command line Name

func NewApp added in v1.5.3

func NewApp(app *cobra.Command) Option

NewApp sets the root of command line

func NewBroker

func NewBroker(name string, b func(...broker.Option) broker.Broker) Option

NewBroker new broker func

func NewClient

func NewClient(name string, b func(...client.Option) client.Client) Option

NewClient new client func

func NewRegistry

func NewRegistry(name string, r func(...registry.Option) registry.Registry) Option

NewRegistry new registry func

func NewSelector

func NewSelector(name string, s func(...selector.Option) selector.Selector) Option

NewSelector new selector func

func NewServer

func NewServer(name string, s func(...server.Option) server.Server) Option

NewServer new server func

func NewTracer

func NewTracer(name string, t func(...trace.Option) trace.Tracer) Option

NewTracer new tracer func

func Registry

func Registry(r *registry.Registry) Option

func Selector

func Selector(s *selector.Selector) Option

func Server

func Server(s *server.Server) Option

func Tracer

func Tracer(t *trace.Tracer) Option

func Version

func Version(v string) Option

Version command line Version

type Options

type Options struct {
	// For the Command Line itself
	Name        string
	Description string
	Version     string

	// We need pointers to things, so we can swap them out if needed.
	Broker   *broker.Broker
	Registry *registry.Registry
	Selector *selector.Selector
	Config   *config.Config
	Client   *client.Client
	Server   *server.Server
	Cache    *cache.Cache
	Tracer   *trace.Tracer

	Brokers    map[string]func(...broker.Option) broker.Broker
	Configs    map[string]func(...config.Option) config.Config
	Clients    map[string]func(...client.Option) client.Client
	Registries map[string]func(...registry.Option) registry.Registry
	Selectors  map[string]func(...selector.Option) selector.Selector
	Servers    map[string]func(...server.Option) server.Server
	Caches     map[string]func(...cache.Option) cache.Cache
	Tracers    map[string]func(...trace.Option) trace.Tracer

	// Other options for implementations of the interfaces
	// can be stored in a context
	Context context.Context
	// contains filtered or unexported fields
}

func DefaultOptions

func DefaultOptions() Options

Jump to

Keyboard shortcuts

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