Documentation
¶
Index ¶
- Constants
- type AckMsgs
- type AmsBaseInfo
- type AmsRequest
- type Attributes
- type AuthorizationHeader
- type Client
- type Message
- type MessageService
- type MockAmsRoundTripper
- type MockConsumeRoundTripper
- type Project
- type PullOptions
- type PushConfig
- type ReceivedMessage
- type ReceivedMessagesList
- type RetryPolicy
- type Subscription
- type SubscriptionService
- type UserInfo
- type UserService
Constants ¶
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 ¶
AmsBaseInfo holds basic information to interact with the ams service
type AmsRequest ¶
AmsRequest contains the necessary data for an ams request to be executed
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
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 ¶
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{}
type MockConsumeRoundTripper ¶
type MockConsumeRoundTripper struct {
RequestBodyBytes []byte
}
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 ¶
func (r *ReceivedMessagesList) Last() ReceivedMessage
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 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 ¶
GetUserByToken uses the provided token to get the respective user profile