subscriptions

package
v1.0.6-1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LinearRetryPolicyType       = "linear"
	SlowStartRetryPolicyType    = "slowstart"
	UnSupportedRetryPolicyError = `Retry policy can only be of 'linear' or 'slowstart' type`
)

Variables

This section is empty.

Functions

func ExtractFullTopicRef

func ExtractFullTopicRef(fTopicRef string) (string, string, error)

ExtractFullTopicRef gets a full topic ref and extracts project and topic refs

func GetMaxAckID

func GetMaxAckID(ackIDs []string) (string, error)

GetMaxAckID gets a list of ack ids and selects the maximum one

func GetOffsetFromAckID

func GetOffsetFromAckID(ackID string) (int64, error)

GetOffsetFromAckID extracts an offset from an ackID

func HasSub

func HasSub(projectUUID string, name string, store stores.Store) bool

HasSub returns true if project & subscription combination exist

func IsRetryPolicySupported

func IsRetryPolicySupported(retPol string) bool

IsRetryPolicySupported checks if the provided retry policy is supported by the service

func ModAck

func ModAck(projectUUID string, name string, ack int, store stores.Store) error

ModAck updates the subscription's acknowledgment timeout

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 RemoveSub

func RemoveSub(projectUUID string, name string, store stores.Store) error

RemoveSub removes an existing subscription

func VerifyPushEndpoint

func VerifyPushEndpoint(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

func GetAckFromJSON(input []byte) (AckIDs, error)

GetAckFromJSON retrieves ack ids from json

type NamesList

type NamesList struct {
	Subscriptions []string `json:"subscriptions"`
}

func FindByTopic

func FindByTopic(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

func (offs *Offsets) ExportJSON() (string, error)

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

func GetSetOffsetJSON(input []byte) (SetOffset, error)

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(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:"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

Jump to

Keyboard shortcuts

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