Documentation ¶
Overview ¶
Package pubsub contains the handling required to connect OCM repositories to publish/subscribe infrastructures. A pubsub system is described by a dedicated specification (de-)serializable by a PubSubType object. The deserialized specification must implement the PubSubSpec interface. It has to be able to provide a pubsub adapter by providing an object implementing the PubSubMethod interface instantiated for a dedicated repository object. This object is then used by the OCM library (if provided) to generate appropriate events when adding/updating a component version for a repository.
The known pubsub types can be registered for an OCM context. This registration mechanism uses a dedicated context attribute. The default type registry can be filled by init functions using the function RegisterType.
The library allows to configure a pub/sub specification at repository level. Therefore, dedicated providers (interface Provider) are used, which are able to extract/provide a pubsub specification from/for a dedicated repository. The task of the provider is to handle the persistence of the serialized data of the specification at repository level. The provider just provides the specification data, it does not know anything about the types and implementations.
Providers are registered at an OCM context for a dedicated type of repository. (the spec kind of the repository spec used to describe the repository). The default provider registry can be filled by init functions using the function RegisterProvider.
To configure dedicated contexts, the contained registry objects can be modified on the attribute provided by For(ctx).
Index ¶
- Constants
- Variables
- func NewStrictTypeScheme(base ...TypeScheme) runtime.VersionedTypeRegistry[PubSubSpec, PubSubType]
- func Notify(repo cpi.Repository, nv common.NameVersion) error
- func PubSubUsage(scheme TypeScheme, providers ProviderRegistry, cli bool) string
- func RegisterProvider(repokind string, prov Provider)
- func RegisterType(atype PubSubType)
- func SetForRepo(repo cpi.Repository, spec PubSubSpec) error
- func SetProvidersFor(ctx cpi.ContextProvider, registry ProviderRegistry)
- func SetSchemeFor(ctx cpi.ContextProvider, registry TypeScheme)
- type Attribute
- type Evaluatable
- type GenericPubSubSpec
- type NopProvider
- type Option
- type Provider
- type ProviderRegistry
- type PubSubMethod
- type PubSubSpec
- type PubSubSpecDecoder
- type PubSubType
- type PubSubTypeProvider
- type TypeScheme
- type UnknownPubSubSpec
- type Unwrapable
Constants ¶
const ATTR_PUBSUB_TYPES = "ocm.software/ocm/api/ocm/extensions/pubsub"
const KIND_PUBSUBTYPE = "pub/sub"
Variables ¶
var DefaultRegistry = NewProviderRegistry()
var DefaultTypeScheme = NewTypeScheme()
DefaultTypeScheme contains all globally known PubSub serializers.
Functions ¶
func NewStrictTypeScheme ¶
func NewStrictTypeScheme(base ...TypeScheme) runtime.VersionedTypeRegistry[PubSubSpec, PubSubType]
func Notify ¶
func Notify(repo cpi.Repository, nv common.NameVersion) error
func PubSubUsage ¶
func PubSubUsage(scheme TypeScheme, providers ProviderRegistry, cli bool) string
func RegisterProvider ¶
func RegisterType ¶
func RegisterType(atype PubSubType)
func SetForRepo ¶
func SetForRepo(repo cpi.Repository, spec PubSubSpec) error
func SetProvidersFor ¶
func SetProvidersFor(ctx cpi.ContextProvider, registry ProviderRegistry)
func SetSchemeFor ¶
func SetSchemeFor(ctx cpi.ContextProvider, registry TypeScheme)
Types ¶
type Attribute ¶
type Attribute struct { ProviderRegistry TypeScheme }
func For ¶
func For(ctx cpi.ContextProvider) *Attribute
type Evaluatable ¶
type Evaluatable interface {
Evaluate(ctx cpi.Context) (PubSubSpec, error)
}
type GenericPubSubSpec ¶
type GenericPubSubSpec struct { runtime.UnstructuredVersionedTypedObject `json:",inline"` // contains filtered or unexported fields }
func ToGenericPubSubSpec ¶
func ToGenericPubSubSpec(spec PubSubSpec) (*GenericPubSubSpec, error)
func (*GenericPubSubSpec) Evaluate ¶
func (s *GenericPubSubSpec) Evaluate(ctx cpi.Context) (PubSubSpec, error)
func (*GenericPubSubSpec) PubSubMethod ¶
func (s *GenericPubSubSpec) PubSubMethod(repository cpi.Repository) (PubSubMethod, error)
func (*GenericPubSubSpec) Unwrap ¶
func (s *GenericPubSubSpec) Unwrap(ctx cpi.Context) []PubSubSpec
type NopProvider ¶
type NopProvider struct{}
func (NopProvider) GetPubSubSpec ¶
func (p NopProvider) GetPubSubSpec(repo cpi.Repository) (PubSubSpec, error)
func (NopProvider) SetPubSubSpec ¶
func (p NopProvider) SetPubSubSpec(repo cpi.Repository, spec PubSubSpec) error
type Provider ¶
type Provider interface { GetPubSubSpec(repo cpi.Repository) (PubSubSpec, error) SetPubSubSpec(repo cpi.Repository, spec PubSubSpec) error }
A Provider is able to extract a pub sub configuration for an ocm repository (typically registered for a dedicated type of repository). It does not handle the pub sub system, but just the persistence of a pub sub specification configured for a dedicated type of repository.
type ProviderRegistry ¶
type ProviderRegistry interface { Register(repoKind string, prov Provider) KnownProviders() map[string]Provider AddKnownProviders(registry ProviderRegistry) For(repo string) Provider }
ProviderRegistry holds handlers able to extract a PubSub specification for an OCM repository of a dedicated kind.
func NewProviderRegistry ¶
func NewProviderRegistry(base ...ProviderRegistry) ProviderRegistry
type PubSubMethod ¶
type PubSubMethod interface {
NotifyComponentVersion(version common.NameVersion) error
}
PubSubMethod is the handler able to publish an OCM component version event.
func PubSubForRepo ¶
func PubSubForRepo(repo cpi.Repository) (PubSubMethod, error)
type PubSubSpec ¶
type PubSubSpec interface { runtime.VersionedTypedObject PubSubMethod(repo cpi.Repository) (PubSubMethod, error) Describe(ctx cpi.Context) string }
PubSubSpec is the interface publish/subscribe specifications must fulfill. The main task is to map the specification to a concrete implementation of the pub/sub adapter which forwards events to the described system.
func CreatePubSubSpec ¶
func CreatePubSubSpec(t runtime.TypedObject) (PubSubSpec, error)
func NewGenericPubSubSpec ¶
func NewGenericPubSubSpec(data []byte, unmarshaler ...runtime.Unmarshaler) (PubSubSpec, error)
func SpecForData ¶
func SpecForData(ctx cpi.ContextProvider, data []byte) (PubSubSpec, error)
func SpecForRepo ¶
func SpecForRepo(repo cpi.Repository) (PubSubSpec, error)
type PubSubSpecDecoder ¶
type PubSubSpecDecoder = runtime.TypedObjectDecoder[PubSubSpec]
type PubSubType ¶
type PubSubType descriptivetype.TypedObjectType[PubSubSpec]
func NewPubSubType ¶
func NewPubSubType[I PubSubSpec](name string, opts ...Option) PubSubType
type PubSubTypeProvider ¶
type PubSubTypeProvider = runtime.KnownTypesProvider[PubSubSpec, PubSubType]
type TypeScheme ¶
type TypeScheme descriptivetype.TypeScheme[PubSubSpec, PubSubType]
TypeScheme is the registry for specification types for PubSub types. A PubSub type is finally able to provide an implementation for notifying a dedicated PubSub instance.
func NewTypeScheme ¶
func NewTypeScheme(base ...TypeScheme) TypeScheme
type UnknownPubSubSpec ¶
type UnknownPubSubSpec struct {
runtime.UnstructuredVersionedTypedObject `json:",inline"`
}
func (*UnknownPubSubSpec) IsUnknown ¶
func (_ *UnknownPubSubSpec) IsUnknown() bool
func (*UnknownPubSubSpec) PubSubMethod ¶
func (s *UnknownPubSubSpec) PubSubMethod(repository cpi.Repository) (PubSubMethod, error)
type Unwrapable ¶
type Unwrapable interface {
Unwrap(ctx cpi.Context) []PubSubSpec
}