api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: MIT Imports: 18 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrApiDisabled = errors.New("the API call is not enabled for this client")

Functions

This section is empty.

Types

type Client

type Client interface {
	io.Closer

	// ReadUsage returns the current usage counts by the requested subject.
	ReadUsage(ctx context.Context, userId string, subj usage.Subject) (u usage.Usage, err error)

	// ReadUsageLimit returns the usage limit by the requested subject.
	ReadUsageLimit(ctx context.Context, userId string, subj usage.Subject) (l usage.Limit, err error)

	// WriteMessages opens the stream for publishing the messages.
	WriteMessages(ctx context.Context, userId string) (ws model.WriteStream[*pb.CloudEvent], err error)

	// ReadMessages opens the stream for receiving the messages matching the requested subscription.
	ReadMessages(ctx context.Context, userId, subId string) (rs model.ReadStream[*pb.CloudEvent], err error)

	// CreateSubscription with the specified fields.
	CreateSubscription(ctx context.Context, userId string, subData subscription.Data) (id string, err error)

	// ReadSubscription specified by the id. Returns ErrNotFound if subscription is missing.
	ReadSubscription(ctx context.Context, userId, subId string) (subData subscription.Data, err error)

	// UpdateSubscriptionMetadata updates the mutable part of the subscription.Data
	UpdateSubscriptionMetadata(ctx context.Context, userId, subId string, md subscription.Metadata) (err error)

	// DeleteSubscription and all associated conditions those not in use by any other subscription.
	// Returns ErrNotFound if a subscription with the specified id is missing.
	DeleteSubscription(ctx context.Context, userId, subId string) (err error)

	// SearchSubscriptions returns all subscription ids those have the requested user id.
	SearchSubscriptions(ctx context.Context, userId string, limit uint32, cursor string) (ids []string, err error)
}

type ClientBuilder

type ClientBuilder interface {

	// ServerPublicKey sets the CA certificate to authenticate the Awakari service.
	// Should be used together with ClientKeyPair and ApiUri.
	ServerPublicKey(caCrt []byte) ClientBuilder

	// ClientKeyPair sets the client certificate key pair to allow Awakari service to authenticate the client.
	// Should be used together with ServerPublicKey and ApiUri.
	ClientKeyPair(clientCrt, clientKey []byte) ClientBuilder

	// ApiUri sets the Awakari public API URI. Should be used together with ServerPublicKey and ClientKeyPair.
	// Useful when a client needs every available public API method.
	ApiUri(apiUri string) ClientBuilder

	// ReadUri sets the Awakari messages reading API URI. Overrides any value set by ApiUri.
	// Useful when the specific message reading API is needed by the client.
	ReadUri(readUri string) ClientBuilder

	// SubscriptionsUri sets the Awakari subscriptions API URI. Overrides any value set by ApiUri.
	// Useful when the specific subscriptions management API is needed by the client.
	SubscriptionsUri(subsUri string) ClientBuilder

	// WriteUri sets the Awakari messages publishing API URI. Overrides any value set by ApiUri.
	// Useful when the specific message publishing API is needed by the client.
	WriteUri(writeUri string) ClientBuilder

	// Build instantiates the Client instance and returns it.
	Build() (c Client, err error)
}

func NewClientBuilder

func NewClientBuilder() ClientBuilder

Directories

Path Synopsis
grpc

Jump to

Keyboard shortcuts

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