Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ServiceRegister = ServiceRegisterType{}
Open for manipulation so the caller can replace services
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service interface {
Invoke(input interface{}) (interface{}, error)
}
A service takes something in, and returns something back when invoked
func FindService ¶
type ServiceConfig ¶
A holder for service metadata
func NewServiceConfig ¶
func NewServiceConfig(name string) *ServiceConfig
func (*ServiceConfig) Arg ¶
func (sc *ServiceConfig) Arg(usage string) *string
func (*ServiceConfig) Flag ¶
func (sc *ServiceConfig) Flag(name, def, usage string) *string
Keep it simple for now, and thus only string flag is supported
func (*ServiceConfig) ParseFlags ¶
func (sc *ServiceConfig) ParseFlags(args ...string) (rest []string, err error)
Parse flags. If anything is left, it is returned in rest, if it doesnt match us, an error is returned
func (*ServiceConfig) Usage ¶
func (sc *ServiceConfig) Usage(fn interface{}) string
func (*ServiceConfig) ValidateFn ¶
func (sc *ServiceConfig) ValidateFn(fn func() error)
type ServiceCreator ¶
type ServiceCreator interface { Create(args ...string) (Service, error) // Type() reflect.Type // Type probably not needed Usage() string // Wait with for now }
func RegisterService ¶
func RegisterService(createFn ServiceCreatorFn) ServiceCreator
type ServiceCreatorFn ¶
type ServiceCreatorFn func() (*ServiceConfig, interface{})
ServiceCreatorFn: Creates the flags for creating a service, and the service function. The use of flag.FlagSet is not final, and might be changed to another input parser
func (ServiceCreatorFn) Usage ¶
func (sc ServiceCreatorFn) Usage() string
type ServiceRegisterType ¶
type ServiceRegisterType []ServiceCreator
func (*ServiceRegisterType) FindService ¶
func (srt *ServiceRegisterType) FindService(args ...string) (Service, error)
func (*ServiceRegisterType) Register ¶
func (srt *ServiceRegisterType) Register(createFn ServiceCreatorFn) ServiceCreator
Click to show internal directories.
Click to hide internal directories.