services

package
v0.0.0-...-e8c81cb Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 5 Imported by: 0

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

func FindService(args ...string) (Service, error)

type ServiceConfig

type ServiceConfig struct {
	Name string

	Next Service
	// contains filtered or unexported fields
}

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) Create

func (sc ServiceCreatorFn) Create(args ...string) (Service, error)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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