v1

package
v0.0.0-...-de41a1e Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpEndpointPushConfig = "http_endpoint"
	MattermostPushConfig   = "mattermost"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AckMsgs

type AckMsgs struct {
	AckIDS []string `json:"ackIds"`
}

AckMsgs the ack ids for the messages we want to acknowledge

type AmsBaseInfo

type AmsBaseInfo struct {
	Scheme  string
	Host    string
	Headers map[string]string
}

AmsBaseInfo holds basic information to interact with the ams service

type AmsRequest

type AmsRequest struct {
	*http.Client
	// contains filtered or unexported fields
}

AmsRequest contains the necessary data for an ams request to be executed

type Attributes

type Attributes map[string]string

Attributes is key/value pairs of extra data

type AuthorizationHeader

type AuthorizationHeader struct {
	Value string `json:"value"`
}

AuthorizationHeader holds an optional value to be supplied as an Authorization header to push requests

type Client

type Client struct {
	*UserService
	*SubscriptionService
	*MessageService
}

Client encapsulates all the possible api calls that a client can use to interface with the ams service

func NewClient

func NewClient(scheme, host, token string, port int, client *http.Client) *Client

NewClient properly initialises a new ams client

func (*Client) Host

func (c *Client) Host() string

type Message

type Message struct {
	// message id
	ID string `json:"messageId,omitempty"`
	// used to hold attribute key/value store
	Attr Attributes `json:"attributes,omitempty"`
	// base64 encoded data payload
	Data string `json:"data"`
	// publish time date of message
	PubTime string `json:"publishTime,omitempty"`
}

Message struct used to hold message information

type MessageService

type MessageService struct {
	AmsBaseInfo
	// contains filtered or unexported fields
}

func NewMessageService

func NewMessageService(info AmsBaseInfo, client *http.Client) *MessageService

NewMessageService properly initialises a message service

func (*MessageService) Ack

func (s *MessageService) Ack(ctx context.Context, subscription string, ackId string) error

Ack acknowledges that an ams message has been consumed and processed Requires the full subscription path .e.g. /projects/project_one/subscriptions/sub_one

func (*MessageService) Pull

func (s *MessageService) Pull(ctx context.Context, subscription string, numberOfMessages int64, returnImmediately bool) (ReceivedMessagesList, error)

Pull consumes messages from an subscription. Requires the full subscription path .e.g. /projects/project_one/subscriptions/sub_one

type MockAmsRoundTripper

type MockAmsRoundTripper struct{}

func (*MockAmsRoundTripper) RoundTrip

func (m *MockAmsRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

type MockConsumeRoundTripper

type MockConsumeRoundTripper struct {
	RequestBodyBytes []byte
}

func (*MockConsumeRoundTripper) RoundTrip

func (m *MockConsumeRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

type Project

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

type PullOptions

type PullOptions struct {
	// amount of messages to be pulled at once
	MaxMessages string `json:"maxMessages"`
	// whether or not it should wait until it gathers
	// the requested amount of maxMessages
	// to be pulled or return with what is available
	ReturnImmediately string `json:"returnImmediately"`
}

PullOptions holds information on how we want to pull messages

type PushConfig

type PushConfig struct {
	Type                string              `json:"type"`
	Pend                string              `json:"pushEndpoint"`
	AuthorizationHeader AuthorizationHeader `json:"authorizationHeader"`
	MaxMessages         int64               `json:"maxMessages"`
	RetPol              RetryPolicy         `json:"retryPolicy"`
	MattermostUrl       string              `json:"mattermostUrl"`
	MattermostUsername  string              `json:"mattermostUsername"`
	MattermostChannel   string              `json:"mattermostChannel"`
	Base64Decode        bool                `json:"base64Decode"`
}

PushConfig holds optional configuration for push operations

type ReceivedMessage

type ReceivedMessage struct {
	// id to be used for acknowledgement
	AckID string `json:"ackId,omitempty"`
	// the message itself
	Msg Message `json:"message"`
}

ReceivedMessage holds info for a received message

type ReceivedMessagesList

type ReceivedMessagesList struct {
	RecMsgs []ReceivedMessage `json:"receivedMessages"`
}

ReceivedMessagesList holds the array of the receivedMessages - subscription related

func (*ReceivedMessagesList) IsEmpty

func (r *ReceivedMessagesList) IsEmpty() bool

IsEmpty returns whether or not a received message list is empty

func (*ReceivedMessagesList) Last

Last returns the last ReceivedMessage of the slice

type RetryPolicy

type RetryPolicy struct {
	PolicyType string `json:"type,omitempty"`
	Period     uint32 `json:"period,omitempty"`
}

RetryPolicy holds information on retry policies

type Subscription

type Subscription struct {
	FullName  string     `json:"name"`
	FullTopic string     `json:"topic"`
	PushCfg   PushConfig `json:"pushConfig"`
}

func (*Subscription) IsPushEnabled

func (s *Subscription) IsPushEnabled() bool

type SubscriptionService

type SubscriptionService struct {
	AmsBaseInfo
	// contains filtered or unexported fields
}

func NewSubscriptionService

func NewSubscriptionService(info AmsBaseInfo, client *http.Client) *SubscriptionService

NewSubscriptionService properly initialises a subscription service

func (*SubscriptionService) GetSubscription

func (s *SubscriptionService) GetSubscription(ctx context.Context, subscription string) (Subscription, error)

GetSubscription retrieves the respective subscription info. Requires the full subscription path .e.g. /projects/project_one/subscriptions/sub_one

type UserInfo

type UserInfo struct {
	Name     string    `json:"name"`
	Projects []Project `json:"projects"`
}

type UserService

type UserService struct {
	AmsBaseInfo
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(info AmsBaseInfo, client *http.Client) *UserService

NewUserService properly initialises a user service

func (*UserService) GetUserByToken

func (us *UserService) GetUserByToken(ctx context.Context, token string) (UserInfo, error)

GetUserByToken uses the provided token to get the respective user profile

Jump to

Keyboard shortcuts

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