Documentation ¶
Index ¶
- Variables
- func WithInitialPublication(publications ...*traits.Publication) resource.Option
- func WithNewPublishTime() resource.WriteOption
- func WithNewVersion() resource.WriteOption
- func WithPublicationApiClientFactory(f func(name string) (traits.PublicationApiClient, error)) router.Option
- func WithPublicationOption(opts ...resource.Option) resource.Option
- func WithResetReceipt() resource.WriteOption
- type ApiRouter
- func (r *ApiRouter) AcknowledgePublication(ctx context.Context, request *traits.AcknowledgePublicationRequest) (*traits.Publication, error)
- func (r *ApiRouter) Add(name string, client any) any
- func (r *ApiRouter) AddPublicationApiClient(name string, client traits.PublicationApiClient) traits.PublicationApiClient
- func (r *ApiRouter) CreatePublication(ctx context.Context, request *traits.CreatePublicationRequest) (*traits.Publication, error)
- func (r *ApiRouter) DeletePublication(ctx context.Context, request *traits.DeletePublicationRequest) (*traits.Publication, error)
- func (r *ApiRouter) GetPublication(ctx context.Context, request *traits.GetPublicationRequest) (*traits.Publication, error)
- func (r *ApiRouter) GetPublicationApiClient(name string) (traits.PublicationApiClient, error)
- func (r *ApiRouter) HoldsType(client any) bool
- func (r *ApiRouter) ListPublications(ctx context.Context, request *traits.ListPublicationsRequest) (*traits.ListPublicationsResponse, error)
- func (r *ApiRouter) PullPublication(request *traits.PullPublicationRequest, ...) error
- func (r *ApiRouter) PullPublications(request *traits.PullPublicationsRequest, ...) error
- func (r *ApiRouter) Register(server grpc.ServiceRegistrar)
- func (r *ApiRouter) RemovePublicationApiClient(name string) traits.PublicationApiClient
- func (r *ApiRouter) UpdatePublication(ctx context.Context, request *traits.UpdatePublicationRequest) (*traits.Publication, error)
- type ApiWrapper
- type Model
- func (m *Model) CreatePublication(publication *traits.Publication, opts ...resource.WriteOption) (*traits.Publication, error)
- func (m *Model) DeletePublication(id string, opts ...resource.WriteOption) (*traits.Publication, error)
- func (m *Model) GetPublication(id string, opts ...resource.ReadOption) (*traits.Publication, bool)
- func (m *Model) ListPublications(opts ...resource.ReadOption) []*traits.Publication
- func (m *Model) PullPublication(ctx context.Context, id string, opts ...resource.ReadOption) <-chan PublicationChange
- func (m *Model) PullPublications(ctx context.Context, opts ...resource.ReadOption) <-chan PublicationsChange
- func (m *Model) UpdatePublication(id string, publication *traits.Publication, opts ...resource.WriteOption) (*traits.Publication, error)
- type ModelOption
- type ModelServer
- func (m *ModelServer) AcknowledgePublication(_ context.Context, request *traits.AcknowledgePublicationRequest) (*traits.Publication, error)
- func (m *ModelServer) CreatePublication(_ context.Context, request *traits.CreatePublicationRequest) (*traits.Publication, error)
- func (m *ModelServer) DeletePublication(_ context.Context, request *traits.DeletePublicationRequest) (*traits.Publication, error)
- func (m *ModelServer) GetPublication(_ context.Context, request *traits.GetPublicationRequest) (*traits.Publication, error)
- func (m *ModelServer) ListPublications(_ context.Context, request *traits.ListPublicationsRequest) (*traits.ListPublicationsResponse, error)
- func (m *ModelServer) PullPublication(request *traits.PullPublicationRequest, ...) error
- func (m *ModelServer) PullPublications(request *traits.PullPublicationsRequest, ...) error
- func (m *ModelServer) Register(server grpc.ServiceRegistrar)
- func (m *ModelServer) Unwrap() any
- func (m *ModelServer) UpdatePublication(_ context.Context, request *traits.UpdatePublicationRequest) (*traits.Publication, error)
- type PublicationChange
- type PublicationsChange
- type WriteOption
Constants ¶
This section is empty.
Variables ¶
var DefaultModelOptions []resource.Option
DefaultModelOptions holds the default options for the model.
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 ¶
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 ¶
type ApiRouter struct { traits.UnimplementedPublicationApiServer router.Router }
ApiRouter is a traits.PublicationApiServer that allows routing named requests to specific traits.PublicationApiClient
func NewApiRouter ¶
func (*ApiRouter) AcknowledgePublication ¶
func (r *ApiRouter) AcknowledgePublication(ctx context.Context, request *traits.AcknowledgePublicationRequest) (*traits.Publication, error)
func (*ApiRouter) Add ¶
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) ListPublications ¶
func (r *ApiRouter) ListPublications(ctx context.Context, request *traits.ListPublicationsRequest) (*traits.ListPublicationsResponse, error)
func (*ApiRouter) PullPublication ¶
func (r *ApiRouter) PullPublication(request *traits.PullPublicationRequest, server traits.PublicationApi_PullPublicationServer) error
func (*ApiRouter) PullPublications ¶
func (r *ApiRouter) PullPublications(request *traits.PullPublicationsRequest, server traits.PublicationApi_PullPublicationsServer) error
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 (*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 ¶
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 (m *ModelServer) ListPublications(_ context.Context, request *traits.ListPublicationsRequest) (*traits.ListPublicationsResponse, error)
func (*ModelServer) PullPublication ¶
func (m *ModelServer) PullPublication(request *traits.PullPublicationRequest, server traits.PublicationApi_PullPublicationServer) error
func (*ModelServer) PullPublications ¶
func (m *ModelServer) PullPublications(request *traits.PullPublicationsRequest, server traits.PublicationApi_PullPublicationsServer) error
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.