Documentation ¶
Index ¶
- Constants
- Variables
- func FirstRun() *version.Version
- func Latest() *version.Version
- func RegisterPluginBoxes(boxes ...PluginBox)
- func RegisterSwaggerJSON(json string)
- func SwaggerSpec() *loads.Document
- func UpdateServiceVersion(ctx context.Context, opts *ServiceOptions) error
- func ValidVersion(v string) *version.Version
- type Convertible
- type IDable
- type Migration
- type MigratorFunc
- type MigratorStatus
- type PluginBox
- type Service
- type ServiceOption
- func AfterServe(f func(ctx context.Context) error) ServiceOption
- func AutoRestart(b bool) ServiceOption
- func AutoStart(b bool) ServiceOption
- func Context(c context.Context) ServiceOption
- func Description(d string) ServiceOption
- func ForceRegister(b bool) ServiceOption
- func Fork(f bool) ServiceOption
- func ID(n string) ServiceOption
- func Metadata(name, value string) ServiceOption
- func Migrations(migrations []*Migration) ServiceOption
- func Name(n string) ServiceOption
- func PluginBoxes(boxes ...PluginBox) ServiceOption
- func Source(s string) ServiceOption
- func Tag(t ...string) ServiceOption
- func Unique(b bool) ServiceOption
- func WithGRPC(f func(context.Context, grpc.ServiceRegistrar) error) ServiceOption
- func WithGRPCStop(f func(context.Context, grpc.ServiceRegistrar) 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, routing.RouteRegistrar) error) ServiceOption
- func WithHTTPOptions(f func(context.Context, routing.RouteRegistrar, *ServiceOptions) error) ServiceOption
- func WithHTTPStop(f func(context.Context, routing.RouteRegistrar) error) ServiceOption
- func WithMigrateIterator(ctxKey any, lister func(ctx context.Context) []string) ServiceOption
- func WithNamedStorageDrivers(name string, f ...any) ServiceOption
- func WithPureHTTP(f func(context.Context, routing.RouteRegistrar) error) ServiceOption
- func WithServer(s server.Server) ServiceOption
- func WithServerScheme(scheme string) ServiceOption
- func WithStorageDrivers(f ...any) ServiceOption
- func WithStorageMigrator(d MigratorFunc) ServiceOption
- func WithTLSConfig(c *tls.Config) ServiceOption
- func WithWeb(handler func(ctx context.Context) WebHandler) ServiceOption
- func WithWebMiddleware(middleware func(h http.Handler) http.Handler) ServiceOption
- func WithWebStop(handler func(ctx context.Context) error) ServiceOption
- type ServiceOptions
- type Stopper
- type StorageDrivers
- type StorageOption
- type StorageOptions
- type WebHandler
Constants ¶
const (
APIRoute = "api"
)
Variables ¶
var (
ContextKey = serviceKey{}
)
Functions ¶
func RegisterPluginBoxes ¶
func RegisterPluginBoxes(boxes ...PluginBox)
RegisterPluginBoxes adds a PluginBox to registry
func RegisterSwaggerJSON ¶
func RegisterSwaggerJSON(json string)
RegisterSwaggerJSON receives a json string and adds it to the swagger definition
func SwaggerSpec ¶
SwaggerSpec returns the swagger specification as a document
func UpdateServiceVersion ¶
func UpdateServiceVersion(ctx context.Context, opts *ServiceOptions) error
UpdateServiceVersion applies migration(s) if necessary and stores new current version for future use.
func ValidVersion ¶
ValidVersion creates a version.NewVersion ignoring the error.
Types ¶
type Convertible ¶
type Convertible interface {
As(interface{}) bool
}
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 MigratorFunc ¶
type MigratorStatus ¶
type PluginBox ¶
PluginBox exposes web assets
func GetRegisteredPluginBoxes ¶
func GetRegisteredPluginBoxes() []PluginBox
GetRegisteredPluginBoxes lists all registered PluginBox
type Service ¶
type Service interface { Init(opts ...ServiceOption) Options() *ServiceOptions Metadata() map[string]string ID() string Name() string Version() string Tags() []string Start(oo ...registry.RegisterOption) error Stop(oo ...registry.RegisterOption) error OnServe(oo ...registry.RegisterOption) error ServerScheme() string Server() server.Server Is(status registry.Status) bool As(i interface{}) bool }
func NewService ¶
func NewService(opts ...ServiceOption) Service
NewService creates a service and directly register it as StatusStopped
type ServiceOption ¶
type ServiceOption func(*ServiceOptions)
ServiceOption provides a functional option
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 Metadata ¶
func Metadata(name, value string) ServiceOption
Metadata registers a key/value metadata
func Migrations ¶
func Migrations(migrations []*Migration) ServiceOption
Migrations option for a service
func PluginBoxes ¶
func PluginBoxes(boxes ...PluginBox) ServiceOption
PluginBoxes option for a service
func WithGRPC ¶
func WithGRPC(f func(context.Context, grpc.ServiceRegistrar) error) ServiceOption
WithGRPC adds a GRPC service handler to the current service
func WithGRPCStop ¶
func WithGRPCStop(f func(context.Context, grpc.ServiceRegistrar) error) ServiceOption
WithGRPCStop hooks to the grpc server stop
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 WithHTTP ¶
func WithHTTP(f func(context.Context, routing.RouteRegistrar) error) ServiceOption
WithHTTP adds a http micro service handler to the current service
func WithHTTPOptions ¶
func WithHTTPOptions(f func(context.Context, routing.RouteRegistrar, *ServiceOptions) error) ServiceOption
WithHTTPOptions adds a http microservice handler to the current service, passing ServiceOptions to initializer
func WithHTTPStop ¶
func WithHTTPStop(f func(context.Context, routing.RouteRegistrar) error) ServiceOption
func WithMigrateIterator ¶
func WithMigrateIterator(ctxKey any, lister func(ctx context.Context) []string) ServiceOption
WithMigrateIterator injects an additional level of iteration for update service version
func WithNamedStorageDrivers ¶
func WithNamedStorageDrivers(name string, f ...any) ServiceOption
WithNamedStorageDrivers allows supporting multiple set of drivers
func WithPureHTTP ¶
func WithPureHTTP(f func(context.Context, routing.RouteRegistrar) error) ServiceOption
WithPureHTTP adds a http micro service handler to the current service
func WithServer ¶
func WithServer(s server.Server) ServiceOption
WithServer directly presets the server.Server instance
func WithServerScheme ¶
func WithServerScheme(scheme string) ServiceOption
func WithStorageDrivers ¶
func WithStorageDrivers(f ...any) ServiceOption
WithStorageDrivers adds a storage handler to the current service
func WithStorageMigrator ¶
func WithStorageMigrator(d MigratorFunc) ServiceOption
WithStorageMigrator provides a Migrate function from one DAO to another
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 WithWebMiddleware ¶
func WithWebMiddleware(middleware func(h http.Handler) http.Handler) ServiceOption
WithWebMiddleware appends additional middleware
func WithWebStop ¶
func WithWebStop(handler func(ctx context.Context) error) ServiceOption
WithWebStop registers an optional callback to perform clean operations on stop WithWeb already registers a serverStop callback to remove rest patterns
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"` Migrations []*Migration `json:"-"` MigrateIterator struct { ContextKey any Lister func(ctx context.Context) []string } `json:"-"` // Port string TLSConfig *tls.Config Server server.Server `json:"-"` // Starting options ForceRegister bool `json:"-"` AutoStart bool `json:"-"` AutoRestart bool `json:"-"` Fork bool `json:"-"` Unique bool `json:"-"` // Before and After funcs BeforeStart []func(context.Context) (context.Context, error) `json:"-"` BeforeStop []func(context.Context) error `json:"-"` BeforeRequest []func(context.Context) (context.Context, error) `json:"-"` AfterServe []func(context.Context) error `json:"-"` WebMiddlewares []func(h http.Handler) http.Handler StorageOptions StorageOptions `json:"-"` // contains filtered or unexported fields }
ServiceOptions stores all options for a pydio service
func (*ServiceOptions) GetRegistry ¶
func (o *ServiceOptions) GetRegistry() registry.Registry
GetRegistry returns the context registry
func (*ServiceOptions) Logger ¶
func (o *ServiceOptions) Logger() log.ZapLogger
Logger returns a local logger
func (*ServiceOptions) RootContext ¶
func (o *ServiceOptions) RootContext() context.Context
RootContext returns root context
func (*ServiceOptions) SetRegistry ¶
func (o *ServiceOptions) SetRegistry(r registry.Registry)
SetRegistry sets the registry in the root context
type StorageDrivers ¶
type StorageDrivers []any
func (*StorageDrivers) Register ¶
func (s *StorageDrivers) Register(f any)
type StorageOption ¶
type StorageOption func(options *StorageOptions)
func WithStoragePrefix ¶
func WithStoragePrefix(i interface{}) StorageOption
WithStoragePrefix sets a prefix to be used differently depending on driver name
type StorageOptions ¶
type StorageOptions struct { SupportedDrivers map[string][]any Handler any Migrator MigratorFunc // contains filtered or unexported fields }
func (*StorageOptions) Prefix ¶
func (o *StorageOptions) Prefix(options *ServiceOptions) string
func (*StorageOptions) ToMeta ¶
func (o *StorageOptions) ToMeta() string
type WebHandler ¶
WebHandler defines what functions a web handler must answer to
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package frontend provides tools to publish static data from within any micro service
|
Package frontend provides tools to publish static data from within any micro service |
Package resources provides extendable service Handler for managing resource-policy based data.
|
Package resources provides extendable service Handler for managing resource-policy based data. |