publication

package
v0.0.0-...-8846729 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 17 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultModelOptions []resource.Option

DefaultModelOptions holds the default options for the model.

View Source
var VersionMismatchErr = status.Error(codes.FailedPrecondition, "version mismatch: update version != server version")

Functions

func WithInitialPublication

func WithInitialPublication(publications ...*traits.Publication) resource.Option

WithInitialPublication configures the model to initialise with the given publication. Can be used multiple times with publications being additive. Creating a model with duplicate publication IDs will panic. Calling this function with an empty publication id property will panic.

func WithNewPublishTime

func WithNewPublishTime() resource.WriteOption

WithNewPublishTime instructs the write operation to calculate a new publish time for the publication.

func WithNewVersion

func WithNewVersion() resource.WriteOption

WithNewVersion instructs a write operation to calculate a new version for the publication.

func WithPublicationApiClientFactory

func WithPublicationApiClientFactory(f func(name string) (traits.PublicationApiClient, error)) router.Option

WithPublicationApiClientFactory instructs the router to create a new client the first time Get is called for that name.

func WithPublicationOption

func WithPublicationOption(opts ...resource.Option) resource.Option

WithPublicationOption configures the publication resource of the model.

func WithResetReceipt

func WithResetReceipt() resource.WriteOption

WithResetReceipt instructs a write operation to reset receipt properties if they exist in the audience for a publication.

Types

type ApiRouter

ApiRouter is a traits.PublicationApiServer that allows routing named requests to specific traits.PublicationApiClient

func NewApiRouter

func NewApiRouter(opts ...router.Option) *ApiRouter

func (*ApiRouter) AcknowledgePublication

func (r *ApiRouter) AcknowledgePublication(ctx context.Context, request *traits.AcknowledgePublicationRequest) (*traits.Publication, error)

func (*ApiRouter) Add

func (r *ApiRouter) Add(name string, client any) any

Add extends Router.Add to panic if client is not of type traits.PublicationApiClient.

func (*ApiRouter) AddPublicationApiClient

func (r *ApiRouter) AddPublicationApiClient(name string, client traits.PublicationApiClient) traits.PublicationApiClient

func (*ApiRouter) CreatePublication

func (r *ApiRouter) CreatePublication(ctx context.Context, request *traits.CreatePublicationRequest) (*traits.Publication, error)

func (*ApiRouter) DeletePublication

func (r *ApiRouter) DeletePublication(ctx context.Context, request *traits.DeletePublicationRequest) (*traits.Publication, error)

func (*ApiRouter) GetPublication

func (r *ApiRouter) GetPublication(ctx context.Context, request *traits.GetPublicationRequest) (*traits.Publication, error)

func (*ApiRouter) GetPublicationApiClient

func (r *ApiRouter) GetPublicationApiClient(name string) (traits.PublicationApiClient, error)

func (*ApiRouter) HoldsType

func (r *ApiRouter) HoldsType(client any) bool

func (*ApiRouter) ListPublications

func (*ApiRouter) PullPublication

func (*ApiRouter) PullPublications

func (*ApiRouter) Register

func (r *ApiRouter) Register(server grpc.ServiceRegistrar)

func (*ApiRouter) RemovePublicationApiClient

func (r *ApiRouter) RemovePublicationApiClient(name string) traits.PublicationApiClient

func (*ApiRouter) UpdatePublication

func (r *ApiRouter) UpdatePublication(ctx context.Context, request *traits.UpdatePublicationRequest) (*traits.Publication, error)

type ApiWrapper

type ApiWrapper struct {
	traits.PublicationApiClient
	// contains filtered or unexported fields
}

func WrapApi

func WrapApi(server traits.PublicationApiServer) *ApiWrapper

WrapApi adapts a traits.PublicationApiServer and presents it as a traits.PublicationApiClient

func (*ApiWrapper) Unwrap

func (w *ApiWrapper) Unwrap() any

Unwrap implements wrap.Unwrapper and returns the underlying server instance as an unknown type.

func (*ApiWrapper) UnwrapServer

func (w *ApiWrapper) UnwrapServer() traits.PublicationApiServer

UnwrapServer returns the underlying server instance.

func (*ApiWrapper) UnwrapService

func (w *ApiWrapper) UnwrapService() (grpc.ClientConnInterface, grpc.ServiceDesc)

type Model

type Model struct {
	// contains filtered or unexported fields
}

func NewModel

func NewModel(opts ...resource.Option) *Model

func (*Model) CreatePublication

func (m *Model) CreatePublication(publication *traits.Publication, opts ...resource.WriteOption) (*traits.Publication, error)

func (*Model) DeletePublication

func (m *Model) DeletePublication(id string, opts ...resource.WriteOption) (*traits.Publication, error)

func (*Model) GetPublication

func (m *Model) GetPublication(id string, opts ...resource.ReadOption) (*traits.Publication, bool)

func (*Model) ListPublications

func (m *Model) ListPublications(opts ...resource.ReadOption) []*traits.Publication

func (*Model) PullPublication

func (m *Model) PullPublication(ctx context.Context, id string, opts ...resource.ReadOption) <-chan PublicationChange

func (*Model) PullPublications

func (m *Model) PullPublications(ctx context.Context, opts ...resource.ReadOption) <-chan PublicationsChange

func (*Model) UpdatePublication

func (m *Model) UpdatePublication(id string, publication *traits.Publication, opts ...resource.WriteOption) (*traits.Publication, error)

type ModelOption

type ModelOption interface {
	resource.Option
	// contains filtered or unexported methods
}

ModelOption defined the base type for all options that apply to this traits model.

type ModelServer

type ModelServer struct {
	traits.UnimplementedPublicationApiServer
	// contains filtered or unexported fields
}

func NewModelServer

func NewModelServer(model *Model) *ModelServer

func (*ModelServer) AcknowledgePublication

func (m *ModelServer) AcknowledgePublication(_ context.Context, request *traits.AcknowledgePublicationRequest) (*traits.Publication, error)

func (*ModelServer) CreatePublication

func (m *ModelServer) CreatePublication(_ context.Context, request *traits.CreatePublicationRequest) (*traits.Publication, error)

func (*ModelServer) DeletePublication

func (m *ModelServer) DeletePublication(_ context.Context, request *traits.DeletePublicationRequest) (*traits.Publication, error)

func (*ModelServer) GetPublication

func (m *ModelServer) GetPublication(_ context.Context, request *traits.GetPublicationRequest) (*traits.Publication, error)

func (*ModelServer) ListPublications

func (*ModelServer) PullPublication

func (*ModelServer) PullPublications

func (*ModelServer) Register

func (m *ModelServer) Register(server grpc.ServiceRegistrar)

func (*ModelServer) Unwrap

func (m *ModelServer) Unwrap() any

func (*ModelServer) UpdatePublication

func (m *ModelServer) UpdatePublication(_ context.Context, request *traits.UpdatePublicationRequest) (*traits.Publication, error)

type PublicationChange

type PublicationChange struct {
	ChangeTime time.Time
	Value      *traits.Publication
}

type PublicationsChange

type PublicationsChange struct {
	ID         string
	ChangeTime time.Time
	ChangeType types.ChangeType
	OldValue   *traits.Publication
	NewValue   *traits.Publication
}

type WriteOption

type WriteOption interface {
	resource.WriteOption
	// contains filtered or unexported methods
}

WriteOption allow extended configuration of write operations for Model.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL