Documentation ¶
Index ¶
- Constants
- Variables
- func AssureUpdater(attrs AttributesContext, u Updater)
- func RegisterAttributeType(name string, typ AttributeType, short ...string) error
- func SetupElement[T ElementCopyable[T]](mode BuilderMode, target *T, create ElementCreator[T], def T) error
- type AttributeFactory
- type AttributeScheme
- type AttributeType
- type Attributes
- type AttributesContext
- type Builder
- type BuilderMode
- type Context
- type ContextIdentity
- type ContextProvider
- type DefaultAttributeType
- type Delegates
- type ElementCopyable
- type ElementCreator
- type InternalContext
- type KnownTypes
- type ObjectKey
- type Session
- type SessionBase
- type UpdateFunc
- type Updater
Constants ¶
const CONTEXT_TYPE = "attributes" + OCM_CONTEXT_SUFFIX
CONTEXT_TYPE is the global type for an attribute context.
const OCM_CONTEXT_SUFFIX = ".context" + common.OCM_TYPE_GROUP_SUFFIX
Variables ¶
var DefaultAttributeScheme = NewDefaulAttritutetScheme()
var DefaultContext = NewWithActions(nil, handlers.DefaultRegistry())
DefaultContext is the default context initialized by init functions.
Functions ¶
func AssureUpdater ¶
func AssureUpdater(attrs AttributesContext, u Updater)
AssureUpdater is used to assure the existence of an updater in a root context if a config context is down the context hierarchy. This method SHOULD only be called by a config context.
func RegisterAttributeType ¶
func RegisterAttributeType(name string, typ AttributeType, short ...string) error
func SetupElement ¶
func SetupElement[T ElementCopyable[T]](mode BuilderMode, target *T, create ElementCreator[T], def T) error
Types ¶
type AttributeFactory ¶
type AttributeFactory func(Context) interface{}
AttributeFactory is used to atomicly create a new attribute for a context.
type AttributeScheme ¶
type AttributeScheme interface { Register(name string, typ AttributeType, short ...string) error Decode(attr string, data []byte, unmarshaler runtime.Unmarshaler) (interface{}, error) Encode(attr string, v interface{}, marshaller runtime.Marshaler) ([]byte, error) GetType(attr string) (AttributeType, error) AddKnownTypes(scheme AttributeScheme) Shortcuts() common.Properties KnownTypes() KnownTypes KnownTypeNames() []string }
func NewDefaulAttritutetScheme ¶
func NewDefaulAttritutetScheme() AttributeScheme
type AttributeType ¶
type Attributes ¶
type Attributes interface { GetAttribute(name string, def ...interface{}) interface{} SetAttribute(name string, value interface{}) error SetEncodedAttribute(name string, data []byte, unmarshaller runtime.Unmarshaler) error GetOrCreateAttribute(name string, creator AttributeFactory) interface{} }
func NewAttributes ¶
func NewAttributes(ctx Context, parent Attributes, updater *Updater) Attributes
type AttributesContext ¶
func ForContext ¶
func ForContext(ctx context.Context) AttributesContext
ForContext returns the Context to use for context.Context. This is either an explicit context or the default context.
func New ¶
func New(parentAttrs Attributes) AttributesContext
New provides a root attribute context.
func NewWithActions ¶
func NewWithActions(parentAttrs Attributes, actions handlers.Registry) AttributesContext
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (Builder) New ¶
func (b Builder) New(m ...BuilderMode) Context
func (Builder) WithActionHandlers ¶
func (Builder) WithAttributes ¶
func (b Builder) WithAttributes(paranetAttr Attributes) Builder
type BuilderMode ¶
type BuilderMode int
BuilderMode controls the handling of unset information in the builder configuration when calling the New method.
const ( // MODE_SHARED uses the default contexts for unset nested context types. MODE_SHARED BuilderMode = iota // MODE_DEFAULTED uses dedicated context instances configured with the // context type specific default registrations. MODE_DEFAULTED // MODE_EXTENDED uses dedicated context instances configured with // context type registrations extending the default registrations. MODE_EXTENDED // MODE_CONFIGURED uses dedicated context instances configured with the // context type registrations configured with the actual state of the // default registrations. MODE_CONFIGURED // MODE_INITIAL uses completely new contexts for unset nested context types // and initial registrations. MODE_INITIAL )
func Mode ¶
func Mode(m ...BuilderMode) BuilderMode
func (BuilderMode) String ¶
func (m BuilderMode) String() string
type Context ¶
type Context interface { ContextProvider Delegates // GetType returns the context type GetType() string GetId() ContextIdentity // BindTo binds the context to a context.Context and makes it // retrievable by a ForContext method BindTo(ctx context.Context) context.Context GetAttributes() Attributes }
Context describes a common interface for a data context used for a dedicated purpose. Such has a type and always specific attribute store. Every Context can be bound to a context.Context.
func ForContextByKey ¶
ForContextByKey retrieves the context for a given key to be used for a context.Context. If not defined, it returns the given default context and false.
func WithContext ¶
WithContext create a new Context bound to a context.Context.
type ContextIdentity ¶
type ContextIdentity = finalizer.ObjectIdentity
type ContextProvider ¶
type ContextProvider interface { // AttributesContext returns the shared attributes AttributesContext() AttributesContext }
type DefaultAttributeType ¶
type DefaultAttributeType struct{}
type Delegates ¶
type Delegates interface { ocmlog.LogProvider handlers.ActionsProvider }
Delegates is the interface for common Context features, which might be delegated to aggregated contexts.
type ElementCopyable ¶
type ElementCopyable[T any] interface { comparable Copy() T }
type ElementCreator ¶
type ElementCreator[T any] func(base ...T) T
type InternalContext ¶
type InternalContext interface { Context finalizer.RecorderProvider }
func NewContextBase ¶
func NewContextBase(eff Context, typ string, key interface{}, parentAttrs Attributes, delegates Delegates) InternalContext
NewContextBase creates a context base implementation supporting context attributes and the binding to a context.Context.
type KnownTypes ¶
type KnownTypes map[string]AttributeType
KnownTypes is a set of known type names mapped to appropriate object decoders.
func (KnownTypes) Copy ¶
func (t KnownTypes) Copy() KnownTypes
Copy provides a copy of the actually known types.
func (KnownTypes) TypeNames ¶
func (t KnownTypes) TypeNames() []string
TypeNames return a sorted list of known type names.
type Session ¶
type Session interface { Closer(closer io.Closer, extra ...interface{}) (io.Closer, error) GetOrCreate(key interface{}, creator func(SessionBase) Session) Session AddCloser(closer io.Closer, callbacks ...accessio.CloserCallback) io.Closer Close() error IsClosed() bool }
Session is a context keeping track of objects requiring a close after final use. When closing a session all subsequent objects will be closed in the opposite order they are added. Added closers may be closed prio to the session without causing errors.
func GetOrCreateSubSession ¶
func GetOrCreateSubSession(s Session, key interface{}, creator func(SessionBase) Session) Session
func NewSession ¶
func NewSession() Session
type SessionBase ¶
type UpdateFunc ¶
type UpdateFunc func() error
func (UpdateFunc) Update ¶
func (u UpdateFunc) Update() error