Documentation ¶
Overview ¶
Package cmd is an interface for parsing the command line
Index ¶
- Variables
- func App() *cli.App
- func Init(opts ...Option) error
- type Cmd
- type Option
- func Broker(b *broker.Broker) Option
- func Client(c *client.Client) Option
- func Config(c *config.Config) Option
- func Description(d string) Option
- func Name(n string) Option
- func NewBroker(name string, b func(...broker.Option) broker.Broker) Option
- func NewClient(name string, b func(...client.Option) client.Client) Option
- func NewRegistry(name string, r func(...registry.Option) registry.Registry) Option
- func NewSelector(name string, s func(...selector.Option) selector.Selector) Option
- func NewServer(name string, s func(...server.Option) server.Server) Option
- func NewTracer(name string, t func(...trace.Option) trace.Tracer) Option
- func NewTransport(name string, t func(...transport.Option) transport.Transport) Option
- func Profile(p *profile.Profile) Option
- func Registry(r *registry.Registry) Option
- func Selector(s *selector.Selector) Option
- func Server(s *server.Server) Option
- func Tracer(t *trace.Tracer) Option
- func Transport(t *transport.Transport) Option
- func Version(v string) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultCmd = newCmd() DefaultFlags = []cli.Flag{ &cli.StringFlag{ Name: "client", EnvVars: []string{"MICRO_CLIENT"}, Usage: "Client for go-micro; rpc", }, &cli.StringFlag{ Name: "client_request_timeout", EnvVars: []string{"MICRO_CLIENT_REQUEST_TIMEOUT"}, Usage: "Sets the client request timeout. e.g 500ms, 5s, 1m. Default: 5s", }, &cli.IntFlag{ Name: "client_retries", EnvVars: []string{"MICRO_CLIENT_RETRIES"}, Value: client.DefaultRetries, Usage: "Sets the client retries. Default: 1", }, &cli.IntFlag{ Name: "client_pool_size", EnvVars: []string{"MICRO_CLIENT_POOL_SIZE"}, Usage: "Sets the client connection pool size. Default: 1", }, &cli.StringFlag{ Name: "client_pool_ttl", EnvVars: []string{"MICRO_CLIENT_POOL_TTL"}, Usage: "Sets the client connection pool ttl. e.g 500ms, 5s, 1m. Default: 1m", }, &cli.IntFlag{ Name: "register_ttl", EnvVars: []string{"MICRO_REGISTER_TTL"}, Value: 60, Usage: "Register TTL in seconds", }, &cli.IntFlag{ Name: "register_interval", EnvVars: []string{"MICRO_REGISTER_INTERVAL"}, Value: 30, Usage: "Register interval in seconds", }, &cli.StringFlag{ Name: "server", EnvVars: []string{"MICRO_SERVER"}, Usage: "Server for go-micro; rpc", }, &cli.StringFlag{ Name: "server_name", EnvVars: []string{"MICRO_SERVER_NAME"}, Usage: "Name of the server. go.micro.srv.example", }, &cli.StringFlag{ Name: "server_version", EnvVars: []string{"MICRO_SERVER_VERSION"}, Usage: "Version of the server. 1.1.0", }, &cli.StringFlag{ Name: "server_id", EnvVars: []string{"MICRO_SERVER_ID"}, Usage: "Id of the server. Auto-generated if not specified", }, &cli.StringFlag{ Name: "server_address", EnvVars: []string{"MICRO_SERVER_ADDRESS"}, Usage: "Bind address for the server. 127.0.0.1:8080", }, &cli.StringFlag{ Name: "server_advertise", EnvVars: []string{"MICRO_SERVER_ADVERTISE"}, Usage: "Used instead of the server_address when registering with discovery. 127.0.0.1:8080", }, &cli.StringSliceFlag{ Name: "server_metadata", EnvVars: []string{"MICRO_SERVER_METADATA"}, Value: &cli.StringSlice{}, Usage: "A list of key-value pairs defining metadata. version=1.0.0", }, &cli.StringFlag{ Name: "broker", EnvVars: []string{"MICRO_BROKER"}, Usage: "Broker for pub/sub. http, nats, rabbitmq", }, &cli.StringFlag{ Name: "broker_address", EnvVars: []string{"MICRO_BROKER_ADDRESS"}, Usage: "Comma-separated list of broker addresses", }, &cli.StringFlag{ Name: "profile", Usage: "Debug profiler for cpu and memory stats", EnvVars: []string{"MICRO_DEBUG_PROFILE"}, }, &cli.StringFlag{ Name: "registry", EnvVars: []string{"MICRO_REGISTRY"}, Usage: "Registry for discovery. etcd, mdns", }, &cli.StringFlag{ Name: "registry_address", EnvVars: []string{"MICRO_REGISTRY_ADDRESS"}, Usage: "Comma-separated list of registry addresses", }, &cli.StringFlag{ Name: "selector", EnvVars: []string{"MICRO_SELECTOR"}, Usage: "Selector used to pick nodes for querying", }, &cli.StringFlag{ Name: "transport", EnvVars: []string{"MICRO_TRANSPORT"}, Usage: "Transport mechanism used; http", }, &cli.StringFlag{ Name: "transport_address", EnvVars: []string{"MICRO_TRANSPORT_ADDRESS"}, Usage: "Comma-separated list of transport addresses", }, &cli.StringFlag{ Name: "tracer", EnvVars: []string{"MICRO_TRACER"}, Usage: "Tracer for distributed tracing, e.g. memory, jaeger", }, &cli.StringFlag{ Name: "tracer_address", EnvVars: []string{"MICRO_TRACER_ADDRESS"}, Usage: "Comma-separated list of tracer addresses", }, &cli.StringFlag{ Name: "config", EnvVars: []string{"MICRO_CONFIG"}, Usage: "The source of the config to be used to get configuration", }, } DefaultBrokers = map[string]func(...broker.Option) broker.Broker{ "service": brokerSrv.NewBroker, "memory": memory.NewBroker, "nats": nats.NewBroker, "http": brokerHttp.NewBroker, } DefaultClients = map[string]func(...client.Option) client.Client{ "grpc": cgrpc.NewClient, } DefaultRegistries = map[string]func(...registry.Option) registry.Registry{ "service": regSrv.NewRegistry, "etcd": etcd.NewRegistry, "mdns": mdns.NewRegistry, "memory": rmem.NewRegistry, } DefaultSelectors = map[string]func(...selector.Option) selector.Selector{ "dns": dns.NewSelector, "router": router.NewSelector, "static": static.NewSelector, } DefaultServers = map[string]func(...server.Option) server.Server{ "mucp": smucp.NewServer, "grpc": sgrpc.NewServer, } DefaultTransports = map[string]func(...transport.Option) transport.Transport{ "memory": tmem.NewTransport, "http": thttp.NewTransport, } DefaultTracers = map[string]func(...trace.Option) trace.Tracer{ "memory": memTracer.NewTracer, } DefaultProfiles = map[string]func(...profile.Option) profile.Profile{ "http": http.NewProfile, "pprof": pprof.NewProfile, } DefaultConfigs = map[string]func(...config.Option) (config.Config, error){ "service": config.NewConfig, } )
Functions ¶
Types ¶
type Cmd ¶
type Option ¶
type Option func(o *Options)
func NewRegistry ¶
New registry func
func NewSelector ¶
New selector func
func NewTransport ¶
New transport func
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 Transport *transport.Transport Config *config.Config Client *client.Client Server *server.Server Tracer *trace.Tracer Profile *profile.Profile Brokers map[string]func(...broker.Option) broker.Broker Configs map[string]func(...config.Option) (config.Config, error) 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 Transports map[string]func(...transport.Option) transport.Transport Tracers map[string]func(...trace.Option) trace.Tracer Profiles map[string]func(...profile.Option) profile.Profile // Other options for implementations of the interface // can be stored in a context Context context.Context }
func DefaultOptions ¶
func DefaultOptions() Options
Click to show internal directories.
Click to hide internal directories.