Documentation
¶
Index ¶
- Constants
- func ExtractFullTopicRef(fTopicRef string) (string, string, error)
- func GetMaxAckID(ackIDs []string) (string, error)
- func GetOffsetFromAckID(ackID string) (int64, error)
- func HasSub(ctx context.Context, projectUUID string, name string, store stores.Store) bool
- func IsAuthorizationHeaderTypeSupported(authzType string) bool
- func IsRetryPolicySupported(retPol string) bool
- func ModAck(ctx context.Context, projectUUID string, name string, ack int, ...) error
- func ModSubPush(ctx context.Context, projectUUID string, name string, pushCfg PushConfig, ...) error
- func RemoveSub(ctx context.Context, projectUUID string, name string, store stores.Store) error
- func VerifyPushEndpoint(ctx context.Context, sub Subscription, c *http.Client, store stores.Store) error
- type AckDeadline
- type AckIDs
- type AuthorizationHeader
- type NamesList
- type Offsets
- type PaginatedSubscriptions
- type PushConfig
- type RetryPolicy
- type SetOffset
- type SubMetrics
- type SubPullOptions
- type Subscription
Constants ¶
const ( LinearRetryPolicyType = "linear" SlowStartRetryPolicyType = "slowstart" AutoGenerationAuthorizationHeader = "autogen" DisabledAuthorizationHeader = "disabled" HttpEndpointPushConfig = "http_endpoint" MattermostPushConfig = "mattermost" UnSupportedRetryPolicyError = `Retry policy can only be of 'linear' or 'slowstart' type` UnSupportedAuthorizationHeader = `Authorization header type can only be of 'autogen' or 'disabled' type` UnsupportedPushConfig = `Push configuration type can only be of 'http_endpoint' or 'mattermost'` )
Variables ¶
This section is empty.
Functions ¶
func ExtractFullTopicRef ¶
ExtractFullTopicRef gets a full topic ref and extracts project and topic refs
func GetMaxAckID ¶
GetMaxAckID gets a list of ack ids and selects the maximum one
func GetOffsetFromAckID ¶
GetOffsetFromAckID extracts an offset from an ackID
func IsAuthorizationHeaderTypeSupported ¶
IsAuthorizationHeaderTypeSupported checks if the provided authorization header type is supported by the service
func IsRetryPolicySupported ¶
IsRetryPolicySupported checks if the provided retry policy is supported by the service
func ModAck ¶
func ModAck(ctx context.Context, projectUUID string, name string, ack int, store stores.Store) error
ModAck updates the subscription's acknowledgment timeout
func ModSubPush ¶
func ModSubPush(ctx context.Context, projectUUID string, name string, pushCfg PushConfig, store stores.Store) error
ModSubPush updates the subscription push config
func VerifyPushEndpoint ¶
func VerifyPushEndpoint(ctx context.Context, sub Subscription, c *http.Client, store stores.Store) error
VerifyPushEndpoint verifies the ownership of a push endpoint
Types ¶
type AckDeadline ¶
type AckDeadline struct {
AckDeadline int `json:"ackDeadlineSeconds"`
}
Ack utility struct
func GetAckDeadlineFromJSON ¶
func GetAckDeadlineFromJSON(input []byte) (AckDeadline, error)
GetAckDeadlineFromJSON retrieves ack deadline from json input
type AckIDs ¶
type AckIDs struct {
IDs []string `json:"AckIds"`
}
AckIDs utility struct
func GetAckFromJSON ¶
GetAckFromJSON retrieves ack ids from json
type AuthorizationHeader ¶
type NamesList ¶
type NamesList struct {
Subscriptions []string `json:"subscriptions"`
}
func FindByTopic ¶
func FindByTopic(ctx context.Context, projectUUID string, topicName string, store stores.Store) (NamesList, error)
FindByTopic retrieves all subscriptions associated with the given topic
func NewNamesList ¶
func NewNamesList() NamesList
type Offsets ¶
type Offsets struct {
Max int64 `json:"max"`
Min int64 `json:"min"`
Current int64 `json:"current"`
}
Offsets is used as a json structure for show offsets Response
func (*Offsets) ExportJSON ¶
ExportJSON exports offsets structure as a json string
type PaginatedSubscriptions ¶
type PaginatedSubscriptions struct {
Subscriptions []Subscription `json:"subscriptions"`
NextPageToken string `json:"nextPageToken"`
TotalSize int64 `json:"totalSize"`
}
PaginatedSubscriptions holds information about a subscriptions' page and how to access the next page
func Find ¶
func Find(ctx context.Context, projectUUID, userUUID, name, pageToken string, pageSize int64, store stores.Store) (PaginatedSubscriptions, error)
Find searches the store for all subscriptions of a given project or a specific one
func LoadPushSubs ¶
func LoadPushSubs(store stores.Store) PaginatedSubscriptions
LoadPushSubs returns all subscriptions defined in store that have a push configuration
func (*PaginatedSubscriptions) Empty ¶
func (sl *PaginatedSubscriptions) Empty() bool
Empty returns true if Subscriptions list has no items
func (*PaginatedSubscriptions) ExportJSON ¶
func (sl *PaginatedSubscriptions) ExportJSON() (string, error)
ExportJSON exports whole sub List Structure as a json string
type PushConfig ¶
type PushConfig struct {
Type string `json:"type"`
Pend string `json:"pushEndpoint"`
MaxMessages int64 `json:"maxMessages"`
AuthorizationHeader AuthorizationHeader `json:"authorizationHeader"`
RetPol RetryPolicy `json:"retryPolicy"`
VerificationHash string `json:"verificationHash"`
Verified bool `json:"verified"`
MattermostUrl string `json:"mattermostUrl"`
MattermostUsername string `json:"mattermostUsername"`
MattermostChannel string `json:"mattermostChannel"`
Base64Decode bool `json:"base64Decode"`
}
PushConfig holds optional configuration for push operations
type RetryPolicy ¶
type RetryPolicy struct {
PolicyType string `json:"type,omitempty"`
Period int `json:"period,omitempty"`
}
RetryPolicy holds information on retry policies
type SetOffset ¶
type SetOffset struct {
Offset int64 `json:"offset"`
}
SetOffset structure is used for input in set Offset Request
func GetSetOffsetJSON ¶
GetSetOffsetJSON retrieves set offset information
type SubMetrics ¶
type SubMetrics struct {
MsgNum int64 `json:"number_of_messages"`
TotalBytes int64 `json:"total_bytes"`
LatestConsume time.Time `json:"-"`
ConsumeRate float64 `json:"-"`
}
SubMetrics holds the subscription's metric details
func FindMetric ¶
func FindMetric(ctx context.Context, projectUUID string, name string, store stores.Store) (SubMetrics, error)
FindMetric returns the metric of a specific subscription
func (*SubMetrics) ExportJSON ¶
func (offs *SubMetrics) ExportJSON() (string, error)
ExportJSON exports metrics as a json string
type SubPullOptions ¶
type SubPullOptions struct {
RetImm string `json:"returnImmediately,omitempty"`
MaxMsg string `json:"maxMessages,omitempty"`
}
SubPullOptions holds info about a pull operation on a subscription
func GetPullOptionsJSON ¶
func GetPullOptionsJSON(input []byte) (SubPullOptions, error)
GetPullOptionsJSON retrieves pull information
type Subscription ¶
type Subscription struct {
ProjectUUID string `json:"-"`
Name string `json:"-"`
Topic string `json:"-"`
FullName string `json:"name"`
FullTopic string `json:"topic"`
PushCfg PushConfig `json:"pushConfig"`
Ack int `json:"ackDeadlineSeconds"`
Offset int64 `json:"-"`
NextOffset int64 `json:"-"`
PendingAck string `json:"-"`
PushStatus string `json:"pushStatus,omitempty"`
CreatedOn string `json:"createdOn"`
LatestConsume time.Time `json:"-"`
ConsumeRate float64 `json:"-"`
}
Subscription struct to hold information for a given topic
func Create ¶
func Create(ctx context.Context, projectUUID string, name string, topic string, offset int64, ack int, pushCfg PushConfig, createdOn time.Time, store stores.Store) (Subscription, error)
Create creates a new subscription
func GetFromJSON ¶
func GetFromJSON(input []byte) (Subscription, error)
GetFromJSON retrieves Sub Info From Json
func New ¶
func New(projectUUID string, projectName string, name string, topic string) Subscription
New creates a new subscription based on name
func (*Subscription) ExportJSON ¶
func (sub *Subscription) ExportJSON() (string, error)
ExportJSON exports whole sub Structure as a json string
func (*Subscription) PushEndpointHost ¶
func (sub *Subscription) PushEndpointHost() string
PushEndpointHost extracts the host:port of a push endpoint