Documentation
¶
Index ¶
- Variables
- func Adapters() map[string]Adapter
- func IsRegistered(adapterID string) bool
- func LoadAllAdapters[T any](adapterID string) ([]T, error)
- func LoadAllAdaptersFrom[T any](r *Registry, adapterID string) ([]T, error)
- func NewAdapterAs[T any](adapterID string, args ...string) (T, error)
- func NewAdapterAsFrom[T any](r *Registry, adapterID string, args ...string) (T, error)
- func Register(adapterID string, f ZeroFactory)
- func SetDefaultSearchMap(sm *SearchMap)
- func SetLogLevel(level LogLevel)
- func SetLogger(l Logger)
- type Adapter
- type Authenticator
- type Browser
- type Builder
- type Configurable
- type Configurer
- type Contextual
- type Creater
- type Deleter
- type DepRef
- type Depender
- type Describer
- type Downloader
- type Executor
- type FileSystem
- type Filter
- type FilterOf
- type Hydrater
- type ItemConfigurable
- type Lifecycle
- type Lister
- type ListerOf
- type LogLevel
- type Logger
- type MetaHeader
- type Pruner
- type Registry
- func (r *Registry) IsRegistered(adapterID string) bool
- func (r *Registry) NewAdapter(adapterID string, args ...string) (Adapter, error)
- func (r *Registry) Register(adapterID string, f ZeroFactory)
- func (r *Registry) SetSearchMap(sm *SearchMap)
- func (r *Registry) SetSearchPath(root string) (*SearchMap, error)
- type Reloader
- type Runner
- type SearchMap
- type Starter
- type Stopper
- type Transferer
- type Updater
- type Uploader
- type ZeroFactory
Constants ¶
This section is empty.
Variables ¶
var ( NewExecutorAdapter = NewAdapterAs[Executor] NewBuilderAdapter = NewAdapterAs[Builder] NewCreaterAdapter = NewAdapterAs[Creater] NewUpdaterAdapter = NewAdapterAs[Updater] NewDeleterAdapter = NewAdapterAs[Deleter] NewReloaderAdapter = NewAdapterAs[Reloader] NewLifecycleAdapter = NewAdapterAs[Lifecycle] NewStarterAdapter = NewAdapterAs[Starter] NewStopperAdapter = NewAdapterAs[Stopper] NewRunnerAdapter = NewAdapterAs[Runner] NewListerAdapter = NewAdapterAs[Lister] NewDescriberAdapter = NewAdapterAs[Describer] NewBrowserAdapter = NewAdapterAs[Browser] NewAuthenticatorAdapter = NewAdapterAs[Authenticator] NewConfigurerAdapter = NewAdapterAs[Configurer] NewUploaderAdapter = NewAdapterAs[Uploader] NewDownloaderAdapter = NewAdapterAs[Downloader] NewTransfererAdapter = NewAdapterAs[Transferer] NewFilterAdapter = NewAdapterAs[Filter] NewPrunerAdapter = NewAdapterAs[Pruner] )
Functions ¶
func Adapters ¶
Adapters returns a shallow copy of the cached adapters of the default registry. (Mostly for debugging / introspection.)
func IsRegistered ¶
func LoadAllAdapters ¶
LoadAllAdapters loads all configured items for adapterID from the default registry.
func LoadAllAdaptersFrom ¶ added in v0.0.5
LoadAllAdaptersFrom loads all configured items for adapterID from the given registry and returns them as []T, skipping items that fail type assertion or construction.
func NewAdapterAs ¶
NewAdapterAs constructs an adapter from the default registry and asserts it implements T.
func NewAdapterAsFrom ¶ added in v0.0.5
NewAdapterAsFrom constructs an adapter from the given registry and asserts it implements T.
func Register ¶
func Register(adapterID string, f ZeroFactory)
Register adds an Adapter constructor to the global registry.
fn MUST return a Adapter that is fully zero-initialised. There should be no heavy lifting
func init() {
core.Register("adapter-id", func() Adapter {
return &GCloud{} // zero cost constructor
})
}
Later the framework will do:
a := registry["adapter-id"]() // clone via factory
if c, ok := a.(Configurable); ok {
cfg := c.ConfigPtr() // returns pointer to struct
loadJSON(cfg) // unmarshal adapter-level config
}
if ic, ok := a.(ItemConfigurable); ok {
itemCfg := ic.ItemConfigPtr() // pointer to per-item struct
loadItemJSON(itemID, itemCfg) // unmarshals one item
}
and run the adapter
func SetDefaultSearchMap ¶ added in v0.0.5
func SetDefaultSearchMap(sm *SearchMap)
(Optional) Lower-level convenience if you already built a SearchMap yourself.
func SetLogLevel ¶ added in v0.0.5
func SetLogLevel(level LogLevel)
SetLogLevel changes the verbosity for the default std logger.
Types ¶
type Authenticator ¶
Authentication
type Configurable ¶
type Configurable interface {
ConfigPtr() any
}
Configurable is called with configurations that match the adapter ID
type Configurer ¶
type Contextual ¶
type Contextual interface {
SetContext(path string) // idempotent environment setup
}
type Executor ¶ added in v0.0.4
type Executor interface {
Run(ctx context.Context, name string, args ...string) error
Output(ctx context.Context, name string, args ...string) ([]byte, error)
}
Executor is a generic "do one unit of work" role. It is intentionally minimal so it can represent pipeline steps, tasks, jobs, commands, etc. in higher-level systems.
type FileSystem ¶ added in v0.0.5
type ItemConfigurable ¶
ItemConfigurable is called for named configurations (name string) Adapters should capture the name here if they're needed. If both a named configuration and adapter configuration exists, both will be called.
type LogLevel ¶ added in v0.0.5
type LogLevel int
LogLevel controls which messages are emitted by the default logger.
func CurrentLogLevel ¶ added in v0.0.5
func CurrentLogLevel() LogLevel
CurrentLogLevel returns the current default log level.
type Logger ¶ added in v0.0.5
type Logger interface {
Debug(v ...any)
Debugf(format string, args ...any)
Info(v ...any)
Infof(format string, args ...any)
Warn(v ...any)
Warnf(format string, args ...any)
Error(v ...any)
Errorf(format string, args ...any)
}
Logger is the common logging interface used by core and adapters.
The non-formatting methods (Debug/Info/Warn/Error) behave like log.Println: they append a single newline. The *f methods ensure exactly one trailing newline even if the format already contains one.
type MetaHeader ¶
type MetaHeader struct {
Name string `json:"name"` // fallback on filename
APIVersion string `json:"api_version"`
Adapter string `json:"adapter,omitempty"`
Dependencies map[string]DepRef `json:"dependencies"`
RawSpec json.RawMessage `json:"spec"` // adapter-specific payload
Context string `json:"context"` // project path (rel or abs)
}
The Context is managed by the system to ensure those paths are adjusted accordingly when the system runs in a container (with volume mounts). Adapters still need to use the value manually to use the context.
func LoadAll ¶
func LoadAll(adapterID string) ([]*MetaHeader, error)
LoadAll is a convenience function that uses the default registry's SearchMap.
type Registry ¶ added in v0.0.5
type Registry struct {
// contains filtered or unexported fields
}
func DefaultRegistry ¶ added in v0.0.5
func DefaultRegistry() *Registry
DefaultRegistry returns the package-global registry used by the helper funcs.
func (*Registry) IsRegistered ¶ added in v0.0.5
IsRegistered reports whether an adapterID has a registered factory.
func (*Registry) NewAdapter ¶ added in v0.0.5
func (*Registry) Register ¶ added in v0.0.5
func (r *Registry) Register(adapterID string, f ZeroFactory)
Register adds an Adapter constructor to the registry.
func (*Registry) SetSearchMap ¶ added in v0.0.5
SetSearchMap sets the SearchMap used by this registry. In typical CLI usage it's set once at startup; we don't worry about races here.
type SearchMap ¶
type SearchMap struct {
Short map[string][]string // basename (no .json) -> []absolute paths
Full map[string]string // relative/key (no .json) -> absolute path
// contains filtered or unexported fields
}
func NewSearchMapWithFS ¶ added in v0.0.5
func NewSearchMapWithFS(root string, fsys FileSystem) (*SearchMap, error)
func SetDefaultSearchPath ¶ added in v0.0.5
Convenience: configure the default registry's search path.
func (*SearchMap) Load ¶
func (sm *SearchMap) Load(name string, verbose bool) (*MetaHeader, error)
Load locates, reads, unmarshals and post-processes a MetaHeader. Should ensure MetaHeader.Name is set.
type Transferer ¶
type Transferer interface {
Uploader
Downloader
}
type ZeroFactory ¶
type ZeroFactory func() Adapter
ZeroFactory should construct a zero-cost, zero-valued adapter.