Documentation ¶
Index ¶
- Constants
- func ExtractFullTopicRef(fTopicRef string) (string, string, error)
- func GetMaxAckID(ackIDs []string) (string, error)
- func GetOffsetFromAckID(ackID string) (int64, error)
- func HasSub(projectUUID string, name string, store stores.Store) bool
- func IsRetryPolicySupported(retPol string) bool
- func ModAck(projectUUID string, name string, ack int, store stores.Store) error
- func ModSubPush(projectUUID string, name string, push string, maxMessages int64, ...) error
- func RemoveSub(projectUUID string, name string, store stores.Store) error
- func VerifyPushEndpoint(sub Subscription, c *http.Client, store stores.Store) error
- type AckDeadline
- type AckIDs
- type NamesList
- type Offsets
- type PaginatedSubscriptions
- type PushConfig
- type RetryPolicy
- type SetOffset
- type SubMetrics
- type SubPullOptions
- type Subscription
Constants ¶
const ( LinearRetryPolicyType = "linear" SlowStartRetryPolicyType = "slowstart" UnSupportedRetryPolicyError = `Retry policy can only be of 'linear' or 'slowstart' type` )
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 IsRetryPolicySupported ¶
IsRetryPolicySupported checks if the provided retry policy is supported by the service
func ModSubPush ¶
func ModSubPush(projectUUID string, name string, push string, maxMessages int64, retPolicy string, retPeriod int, vhash string, verified bool, store stores.Store) error
ModSubPush updates the subscription push config
func VerifyPushEndpoint ¶
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 NamesList ¶
type NamesList struct {
Subscriptions []string `json:"subscriptions"`
}
func FindByTopic ¶
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 int32 `json:"totalSize"` }
PaginatedSubscriptions holds information about a subscriptions' page and how to access the next page
func Find ¶
func Find(projectUUID, userUUID, name, pageToken string, pageSize int32, 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 { Pend string `json:"pushEndpoint"` MaxMessages int64 `json:"maxMessages"` RetPol RetryPolicy `json:"retryPolicy"` VerificationHash string `json:"verification_hash"` Verified bool `json:"verified"` }
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 ¶
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:"push_status,omitempty"` LatestConsume time.Time `json:"-"` ConsumeRate float64 `json:"-"` }
Subscription struct to hold information for a given topic
func CreateSub ¶
func CreateSub(projectUUID string, name string, topic string, push string, offset int64, maxMessages int64, ack int, retPolicy string, retPeriod int, vhash string, verified bool, store stores.Store) (Subscription, error)
CreateSub 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