Documentation
¶
Index ¶
- Variables
- func Address(addr string) xctrl.Option
- func AfterStart(fn func() error) xctrl.Option
- func AfterStop(fn func() error) xctrl.Option
- func BeforeStart(fn func() error) xctrl.Option
- func BeforeStop(fn func() error) xctrl.Option
- func Broker(b broker.Broker) xctrl.Option
- func Client(c client.Client) xctrl.Option
- func Context(ctx context.Context) xctrl.Option
- func HandleSignal(b bool) xctrl.Option
- func LogMiddlewareWrapper(fn server.HandlerFunc) server.HandlerFunc
- func Metadata(md map[string]string) xctrl.Option
- func Name(n string) xctrl.Option
- func NewContext(ctx context.Context, s Service) context.Context
- func Parse()
- func ParseRequest(req server.Request) []byte
- func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error
- func RegisterInterval(t time.Duration) xctrl.Option
- func RegisterSubscriber(topic string, s server.Server, h interface{}, opts ...server.SubscriberOption) error
- func RegisterTTL(t time.Duration) xctrl.Option
- func Registry(r registry.Registry) xctrl.Option
- func Selector(s selector.Selector) xctrl.Option
- func Server(s server.Server) xctrl.Option
- func Version(v string) xctrl.Option
- func WrapCall(w ...client.CallWrapper) xctrl.Option
- func WrapClient(w ...client.Wrapper) xctrl.Option
- func WrapHandler(w ...server.HandlerWrapper) xctrl.Option
- func WrapSubscriber(w ...server.SubscriberWrapper) xctrl.Option
- type Envflag
- type Option
- type Response
- type Service
Constants ¶
This section is empty.
Variables ¶
var DefaultEnvflag = &Envflag{ Cli: flag.CommandLine, }
DefaultEnvflag is the default Envflag and is used by Parse.
Functions ¶
func AfterStart ¶
func BeforeStart ¶
func BeforeStop ¶
func Context ¶
Context specifies a context for the service. Can be used to signal shutdown of the service. Can be used for extra option values.
func HandleSignal ¶
HandleSignal toggles automatic installation of the signal handler that traps TERM, INT, and QUIT. Users of this feature to disable the signal handler, should control liveness of the service through the context.
func LogMiddlewareWrapper ¶
func LogMiddlewareWrapper(fn server.HandlerFunc) server.HandlerFunc
LogMiddlewareWrapper 请求日志中间件
func NewContext ¶
NewContext returns a new Context with the Service embedded within it.
func Parse ¶
func Parse()
Parse parses the command-line flags from os.Args[1:]. Must be called after all flags are defined and before flags are accessed by the program.
func RegisterHandler ¶
func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error
RegisterHandler is syntactic sugar for registering a handler
func RegisterInterval ¶
RegisterInterval specifies the interval on which to re-register
func RegisterSubscriber ¶
func RegisterSubscriber(topic string, s server.Server, h interface{}, opts ...server.SubscriberOption) error
RegisterSubscriber is syntactic sugar for registering a subscriber
func RegisterTTL ¶
RegisterTTL specifies the TTL to use when registering the service
func WrapCall ¶
func WrapCall(w ...client.CallWrapper) xctrl.Option
WrapCall is a convenience method for wrapping a Client CallFunc
func WrapClient ¶
WrapClient is a convenience method for wrapping a Client with some middleware component. A list of wrappers can be provided. Wrappers are applied in reverse order so the last is executed first.
func WrapHandler ¶
func WrapHandler(w ...server.HandlerWrapper) xctrl.Option
WrapHandler adds a handler Wrapper to a list of options passed into the server
func WrapSubscriber ¶
func WrapSubscriber(w ...server.SubscriberWrapper) xctrl.Option
WrapSubscriber adds a subscriber Wrapper to a list of options passed into the server
Types ¶
type Service ¶
type Service interface {
// The service name
Name() string
// Init initialises options
Init(...xctrl.Option)
// Options returns the current options
Options() xctrl.Options
// Client is used to call services
Client() client.Client
// Server is for handling requests and events
Server() server.Server
// Run the service
Run() error
// The service implementation
String() string
}
Service is an interface that wraps the lower level libraries within stack-rpc. Its a convenience method for building and initialising services.
func FromContext ¶
FromContext retrieves a Service from the Context.