Documentation
¶
Index ¶
- func FirstRun() *version.Version
- func Latest() *version.Version
- func RegisterSwaggerJSON(json string)
- func RestError401(req *restful.Request, resp *restful.Response, err error)
- func RestError403(req *restful.Request, resp *restful.Response, err error)
- func RestError404(req *restful.Request, resp *restful.Response, err error)
- func RestError423(req *restful.Request, resp *restful.Response, err error)
- func RestError500(req *restful.Request, resp *restful.Response, err error)
- func RestError503(req *restful.Request, resp *restful.Response, err error)
- func RestErrorDetect(req *restful.Request, resp *restful.Response, err error, defaultCode ...int32)
- func SwaggerSpec() *loads.Document
- func UpdateServiceVersion(opts *ServiceOptions) error
- func ValidVersion(v string) *version.Version
- type ChildrenRunner
- func (c *ChildrenRunner) FilterOutSource(ctx context.Context, sourceName string) bool
- func (c *ChildrenRunner) OnDeleteConfig(callback func(context.Context, string))
- func (c *ChildrenRunner) Start(ctx context.Context, source string, retries ...int) error
- func (c *ChildrenRunner) StartFromInitialConf(ctx context.Context, cfg configx.Values)
- func (c *ChildrenRunner) StopAll(ctx context.Context)
- func (c *ChildrenRunner) Watch(ctx context.Context) error
- type Migration
- type ProtoEntityReaderWriter
- type ServerProvider
- type Service
- type ServiceOption
- func AfterServe(f func(ctx context.Context) error) ServiceOption
- func AfterStart(f func(ctx context.Context) error) ServiceOption
- func AutoRestart(b bool) ServiceOption
- func AutoStart(b bool) ServiceOption
- func Cancel(c context.CancelFunc) ServiceOption
- func Context(c context.Context) ServiceOption
- func Dependency(n string, t []string) ServiceOption
- func Description(d string) ServiceOption
- func Fork(f bool) ServiceOption
- func Metadata(name, value string) ServiceOption
- func Migrations(migrations []*Migration) ServiceOption
- func Name(n string) ServiceOption
- func PluginBoxes(boxes ...frontend.PluginBox) ServiceOption
- func Source(s string) ServiceOption
- func Tag(t ...string) ServiceOption
- func Unique(b bool) ServiceOption
- func WithChildrenRunner(parentName string, childrenPrefix string, cleanEndpointBeforeDelete bool, ...) ServiceOption
- func WithGRPC(f func(context.Context, *grpc.Server) error) ServiceOption
- func WithGRPCStop(f func(context.Context, *grpc.Server) error) ServiceOption
- func WithGeneric(f func(context.Context, *generic.Server) error) ServiceOption
- func WithGenericStop(f func(context.Context, *generic.Server) error) ServiceOption
- func WithHTTP(f func(context.Context, server.HttpMux) error) ServiceOption
- func WithHTTPStop(f func(context.Context, server.HttpMux) error) ServiceOption
- func WithIndexer(fd func(dao.DAO) dao.DAO, opts ...StorageOption) ServiceOption
- func WithLogger(logger log.ZapLogger) ServiceOption
- func WithServer(s server.Server) ServiceOption
- func WithServerProvider(provider ServerProvider) ServiceOption
- func WithStorage(fd func(dao.DAO) dao.DAO, opts ...StorageOption) ServiceOption
- func WithTLSConfig(c *tls.Config) ServiceOption
- func WithWeb(handler func(ctx context.Context) WebHandler) ServiceOption
- func WithWebSession(excludes ...string) ServiceOption
- func WithWebStop(handler func() WebHandler) ServiceOption
- type ServiceOptions
- type Stopper
- type StorageOption
- type StorageOptions
- type WebHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterSwaggerJSON ¶
func RegisterSwaggerJSON(json string)
RegisterSwaggerJSON receives a json string and adds it to the swagger definition
func RestError401 ¶
RestError401 logs the error with context and write an Error 401 on the response.
func RestError403 ¶
RestError403 logs the error with context and write an Error 403 on the response.
func RestError404 ¶
RestError404 logs the error with context and writes an Error 404 on the response.
func RestError423 ¶
RestError423 logs the error with context and write an Error 423 on the response.
func RestError500 ¶
RestError500 logs the error with context and write an Error 500 on the response.
func RestError503 ¶
RestError503 logs the error with context and write an Error 503 on the response.
func RestErrorDetect ¶
RestErrorDetect parses the error and tries to detect the correct code.
func SwaggerSpec ¶
SwaggerSpec returns the swagger specification as a document
func UpdateServiceVersion ¶
func UpdateServiceVersion(opts *ServiceOptions) error
UpdateServiceVersion applies migration(s) if necessary and stores new current version for future use.
func ValidVersion ¶
func ValidVersion(v string) *version.Version
ValidVersion creates a version.NewVersion ignoring the error.
Types ¶
type ChildrenRunner ¶
type ChildrenRunner struct {
// contains filtered or unexported fields
}
ChildrenRunner For Regexp based service
func NewChildrenRunner ¶
func NewChildrenRunner(parentName string, childPrefix string) *ChildrenRunner
NewChildrenRunner creates a ChildrenRunner
func (*ChildrenRunner) FilterOutSource ¶
func (c *ChildrenRunner) FilterOutSource(ctx context.Context, sourceName string) bool
FilterOutSource checks in the actual source config if there are some keys that would prevent running on this node
func (*ChildrenRunner) OnDeleteConfig ¶
func (c *ChildrenRunner) OnDeleteConfig(callback func(context.Context, string))
OnDeleteConfig defines what's happening when the config related to the service is deleted
func (*ChildrenRunner) StartFromInitialConf ¶
func (c *ChildrenRunner) StartFromInitialConf(ctx context.Context, cfg configx.Values)
StartFromInitialConf list the sources keys and start them
func (*ChildrenRunner) StopAll ¶
func (c *ChildrenRunner) StopAll(ctx context.Context)
StopAll services
type Migration ¶
type Migration struct { TargetVersion *version.Version Up func(ctx context.Context) error Down func(ctx context.Context) error }
Migration defines a target version and functions to upgrade and/or downgrade.
type ProtoEntityReaderWriter ¶
type ProtoEntityReaderWriter struct { }
ProtoEntityReaderWriter can read and write values using an encoding such as JSON,XML.
func (*ProtoEntityReaderWriter) Read ¶
func (e *ProtoEntityReaderWriter) Read(req *restful.Request, v interface{}) error
Read a serialized version of the value from the request. The Request may have a decompressing reader. Depends on Content-Encoding.
func (*ProtoEntityReaderWriter) Write ¶
func (e *ProtoEntityReaderWriter) Write(resp *restful.Response, status int, v interface{}) error
Write a serialized version of the value on the response. The Response may have a compressing writer. Depends on Accept-Encoding. status should be a valid Http Status code
type Service ¶
type Service interface { Init(opts ...ServiceOption) Options() *ServiceOptions Metadata() map[string]string ID() string Name() string Start() error Stop() error IsGRPC() bool IsREST() bool IsGeneric() bool As(i interface{}) bool }
func NewService ¶
func NewService(opts ...ServiceOption) Service
type ServiceOption ¶
type ServiceOption func(*ServiceOptions)
func AfterServe ¶
func AfterServe(f func(ctx context.Context) error) ServiceOption
AfterServe registers a callback that is run after Server is finally started (non-blocking)
func AfterStart ¶
func AfterStart(f func(ctx context.Context) error) ServiceOption
AfterStart registers a callback to be run after service.Start (blocking)
func Dependency ¶
func Dependency(n string, t []string) ServiceOption
Dependency option for a service
func Metadata ¶
func Metadata(name, value string) ServiceOption
func Migrations ¶
func Migrations(migrations []*Migration) ServiceOption
Migrations option for a service
func PluginBoxes ¶
func PluginBoxes(boxes ...frontend.PluginBox) ServiceOption
PluginBoxes option for a service
func WithChildrenRunner ¶
func WithChildrenRunner(parentName string, childrenPrefix string, cleanEndpointBeforeDelete bool, afterDeleteListener func(context.Context, string)) ServiceOption
WithChildrenRunner option to define a micro server that runs children services
func WithGRPCStop ¶
func WithGeneric ¶
WithGeneric adds a http micro service handler to the current service
func WithGenericStop ¶
WithGenericStop adds a http micro service handler to the current service
func WithHTTPStop ¶
func WithIndexer ¶
func WithIndexer(fd func(dao.DAO) dao.DAO, opts ...StorageOption) ServiceOption
WithIndexer adds an indexer handler to the current service
func WithLogger ¶
func WithLogger(logger log.ZapLogger) ServiceOption
WithLogger adds a logger to the service context
func WithServer ¶
func WithServer(s server.Server) ServiceOption
WithServer directly presets the server.Server instance
func WithServerProvider ¶
func WithServerProvider(provider ServerProvider) ServiceOption
WithServerProvider passes a callback producing a new server.Server
func WithStorage ¶
func WithStorage(fd func(dao.DAO) dao.DAO, opts ...StorageOption) ServiceOption
WithStorage adds a storage handler to the current service
func WithTLSConfig ¶
func WithTLSConfig(c *tls.Config) ServiceOption
WithTLSConfig option for a service
func WithWeb ¶
func WithWeb(handler func(ctx context.Context) WebHandler) ServiceOption
WithWeb returns a web handler
func WithWebSession ¶
func WithWebSession(excludes ...string) ServiceOption
func WithWebStop ¶
func WithWebStop(handler func() WebHandler) ServiceOption
type ServiceOptions ¶
type ServiceOptions struct { Name string `json:"name"` ID string `json:"id"` Tags []string `json:"tags"` Version string `json:"version"` Description string `json:"description"` Source string `json:"source"` Metadata map[string]string `json:"metadata"` Context context.Context `json:"-"` Cancel context.CancelFunc `json:"-"` Migrations []*Migration `json:"-"` // Port string TLSConfig *tls.Config Server server.Server `json:"-"` ServerProvider ServerProvider `json:"-"` Dependencies []*dependency `json:"-"` // Starting options AutoStart bool `json:"-"` AutoRestart bool `json:"-"` Fork bool `json:"-"` Unique bool `json:"-"` // Before and After funcs BeforeStart []func(context.Context) error `json:"-"` AfterStart []func(context.Context) error `json:"-"` AfterServe []func(context.Context) error `json:"-"` BeforeStop []func(context.Context) error `json:"-"` AfterStop []func(context.Context) error `json:"-"` UseWebSession bool `json:"-"` WebSessionExcludes []string `json:"-"` Storages []*StorageOptions `json:"-"` // contains filtered or unexported fields }
ServiceOptions stores all options for a pydio service
type StorageOption ¶
type StorageOption func(options *StorageOptions)
func WithStorageDefaultDriver ¶
func WithStorageDefaultDriver(d func() (string, string)) StorageOption
WithStorageDefaultDriver provides a default driver/dsn couple if not set in the configuration
func WithStorageMigrator ¶
func WithStorageMigrator(d dao.MigratorFunc) StorageOption
WithStorageMigrator provides a Migrate function from one DAO to another
func WithStoragePrefix ¶
func WithStoragePrefix(i interface{}) StorageOption
WithStoragePrefix sets a prefix to be used differently depending on driver name
func WithStorageSupport ¶
func WithStorageSupport(dd ...string) StorageOption
WithStorageSupport declares wich drivers can be supported by this service
type StorageOptions ¶
type StorageOptions struct { StorageKey string SupportedDrivers []string DefaultDriver dao.DriverProviderFunc Migrator dao.MigratorFunc // contains filtered or unexported fields }
func (*StorageOptions) Prefix ¶
func (o *StorageOptions) Prefix(options *ServiceOptions) string
type WebHandler ¶
WebHandler defines what functions a web handler must answer to
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package servicecontext performs context values read/write, generally through server or client wrappers
|
Package servicecontext performs context values read/write, generally through server or client wrappers |
Package frontend provides tools to publish static data from within any micro service It implements a simple Union HttpFS to be exposed by a standard net.HttpFileServer interface.
|
Package frontend provides tools to publish static data from within any micro service It implements a simple Union HttpFS to be exposed by a standard net.HttpFileServer interface. |
Package resources provides extendable service Handler for managing resource-policy based data.
|
Package resources provides extendable service Handler for managing resource-policy based data. |