Documentation ¶
Index ¶
- type APNSMessageHandler
- type APNSPushQueue
- type CCSMessageWithMetadata
- type GCMMessageHandler
- type KafkaConsumer
- type KafkaGCMMessage
- type KafkaProducer
- type Notification
- type PGClient
- type ParsedTopic
- type StatsD
- func (s *StatsD) Cleanup() error
- func (s *StatsD) HandleNotificationFailure(game string, platform string, err *errors.PushError)
- func (s *StatsD) HandleNotificationSent(game string, platform string)
- func (s *StatsD) HandleNotificationSuccess(game string, platform string)
- func (s *StatsD) InitializeFailure(game string, platform string)
- func (s *StatsD) ReportGoStats(numGoRoutines int, ...)
- func (s *StatsD) ReportMetricCount(metric string, value int64, game, platform string)
- func (s *StatsD) ReportMetricGauge(metric string, value float64, game, platform string)
- type TimeoutHeap
- func (th *TimeoutHeap) AddRequest(deviceToken string)
- func (th *TimeoutHeap) HasExpiredRequest() (string, bool)
- func (th TimeoutHeap) Len() int
- func (th TimeoutHeap) Less(i, j int) bool
- func (th *TimeoutHeap) Pop() interface{}
- func (th *TimeoutHeap) Push(x interface{})
- func (th TimeoutHeap) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APNSMessageHandler ¶
type APNSMessageHandler struct { StatsReporters []interfaces.StatsReporter PushQueue interfaces.APNSPushQueue Topic string Config *viper.Viper InflightMessagesMetadata map[string]interface{} Logger *log.Logger LogStatsInterval time.Duration CacheCleaningInterval int IsProduction bool // contains filtered or unexported fields }
APNSMessageHandler implements the messagehandler interface.
func NewAPNSMessageHandler ¶
func NewAPNSMessageHandler( authKeyPath, keyID, teamID, topic, appName string, isProduction bool, config *viper.Viper, logger *log.Logger, pendingMessagesWG *sync.WaitGroup, statsReporters []interfaces.StatsReporter, feedbackReporters []interfaces.FeedbackReporter, pushQueue interfaces.APNSPushQueue, ) (*APNSMessageHandler, error)
NewAPNSMessageHandler returns a new instance of a APNSMessageHandler.
func (*APNSMessageHandler) CleanMetadataCache ¶ added in v1.1.0
func (a *APNSMessageHandler) CleanMetadataCache()
CleanMetadataCache clears expired requests from memory.
func (*APNSMessageHandler) Cleanup ¶ added in v0.2.0
func (a *APNSMessageHandler) Cleanup() error
Cleanup closes connections to APNS.
func (*APNSMessageHandler) HandleMessages ¶
func (a *APNSMessageHandler) HandleMessages(message interfaces.KafkaMessage)
HandleMessages get messages from msgChan and send to APNS.
func (*APNSMessageHandler) HandleResponses ¶
func (a *APNSMessageHandler) HandleResponses()
HandleResponses from apns.
func (*APNSMessageHandler) LogStats ¶ added in v1.0.0
func (a *APNSMessageHandler) LogStats()
LogStats from time to time.
type APNSPushQueue ¶
type APNSPushQueue struct { Logger *log.Logger Config *viper.Viper IsProduction bool Closed bool // contains filtered or unexported fields }
APNSPushQueue implements interfaces.APNSPushQueue
func NewAPNSPushQueue ¶
func NewAPNSPushQueue( authKeyPath, keyID, teamID string, isProduction bool, logger *log.Logger, config *viper.Viper, ) *APNSPushQueue
NewAPNSPushQueue returns a new instance of a APNSPushQueue
func (*APNSPushQueue) Configure ¶
func (p *APNSPushQueue) Configure() error
Configure configures queues and token
func (*APNSPushQueue) Push ¶
func (p *APNSPushQueue) Push(notification *apns2.Notification)
Push sends the notification
func (*APNSPushQueue) ResponseChannel ¶
func (p *APNSPushQueue) ResponseChannel() chan *structs.ResponseWithMetadata
ResponseChannel returns the response channel
type CCSMessageWithMetadata ¶ added in v0.2.0
type CCSMessageWithMetadata struct { gcm.CCSMessage Timestamp int64 `json:"timestamp"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
CCSMessageWithMetadata is a enriched CCSMessage with a metadata field
type GCMMessageHandler ¶
type GCMMessageHandler struct { StatsReporters []interfaces.StatsReporter GCMClient interfaces.GCMClient Config *viper.Viper InflightMessagesMetadata map[string]interface{} Logger *log.Entry LogStatsInterval time.Duration PingInterval int PingTimeout int CacheCleaningInterval int IsProduction bool // contains filtered or unexported fields }
GCMMessageHandler implements the messagehandler interface
func NewGCMMessageHandler ¶
func NewGCMMessageHandler( senderID, apiKey, game string, isProduction bool, config *viper.Viper, logger *log.Logger, pendingMessagesWG *sync.WaitGroup, statsReporters []interfaces.StatsReporter, feedbackReporters []interfaces.FeedbackReporter, client interfaces.GCMClient, ) (*GCMMessageHandler, error)
NewGCMMessageHandler returns a new instance of a GCMMessageHandler
func (*GCMMessageHandler) CleanMetadataCache ¶ added in v1.1.0
func (g *GCMMessageHandler) CleanMetadataCache()
CleanMetadataCache clears cache after timeout
func (*GCMMessageHandler) Cleanup ¶ added in v0.2.0
func (g *GCMMessageHandler) Cleanup() error
Cleanup closes connections to GCM
func (*GCMMessageHandler) HandleMessages ¶
func (g *GCMMessageHandler) HandleMessages(msg interfaces.KafkaMessage)
HandleMessages get messages from msgChan and send to GCM
func (*GCMMessageHandler) HandleResponses ¶
func (g *GCMMessageHandler) HandleResponses()
HandleResponses from gcm
func (*GCMMessageHandler) LogStats ¶ added in v1.0.0
func (g *GCMMessageHandler) LogStats()
LogStats from time to time
type KafkaConsumer ¶ added in v0.2.0
type KafkaConsumer struct { Topics []string Brokers string Consumer interfaces.KafkaConsumerClient ConsumerGroup string OffsetResetStrategy string Config *viper.Viper ChannelSize int Logger *logrus.Logger FetchMinBytes int FetchWaitMaxMs int SessionTimeout int HandleAllMessagesBeforeExiting bool // contains filtered or unexported fields }
KafkaConsumer for getting push requests
func NewKafkaConsumer ¶ added in v0.2.0
func NewKafkaConsumer( config *viper.Viper, logger *logrus.Logger, stopChannel *chan struct{}, clientOrNil ...interfaces.KafkaConsumerClient, ) (*KafkaConsumer, error)
NewKafkaConsumer for creating a new KafkaConsumer instance
func (*KafkaConsumer) Cleanup ¶ added in v0.2.0
func (q *KafkaConsumer) Cleanup() error
Cleanup closes kafka consumer connection
func (*KafkaConsumer) ConsumeLoop ¶ added in v0.2.0
func (q *KafkaConsumer) ConsumeLoop() error
ConsumeLoop consume messages from the queue and put in messages to send channel
func (*KafkaConsumer) MessagesChannel ¶ added in v0.2.0
func (q *KafkaConsumer) MessagesChannel() *chan interfaces.KafkaMessage
MessagesChannel returns the channel that will receive all messages got from kafka
func (*KafkaConsumer) PendingMessagesWaitGroup ¶ added in v0.2.0
func (q *KafkaConsumer) PendingMessagesWaitGroup() *sync.WaitGroup
PendingMessagesWaitGroup returns the waitGroup that is incremented every time a push is consumed
func (*KafkaConsumer) StopConsuming ¶ added in v0.2.0
func (q *KafkaConsumer) StopConsuming()
StopConsuming stops consuming messages from the queue
type KafkaGCMMessage ¶ added in v0.2.0
type KafkaGCMMessage struct { gcm.XMPPMessage Metadata map[string]interface{} `json:"metadata,omitempty"` PushExpiry int64 `json:"push_expiry,omitempty"` }
KafkaGCMMessage is a enriched XMPPMessage with a Metadata field
type KafkaProducer ¶ added in v0.2.0
type KafkaProducer struct { Brokers string Config *viper.Viper Producer interfaces.KafkaProducerClient BatchSize int LingerMs int Logger *log.Logger Topic string }
KafkaProducer for producing push feedbacks to a kafka queue
func NewKafkaProducer ¶ added in v0.2.0
func NewKafkaProducer(config *viper.Viper, logger *log.Logger, clientOrNil ...interfaces.KafkaProducerClient) (*KafkaProducer, error)
NewKafkaProducer for creating a new KafkaProducer instance
func (*KafkaProducer) SendFeedback ¶ added in v0.2.0
func (q *KafkaProducer) SendFeedback(game string, platform string, feedback []byte)
SendFeedback sends the feedback to the kafka Queue
type Notification ¶
type Notification struct { DeviceToken string Payload interface{} Metadata map[string]interface{} `json:"metadata,omitempty"` PushExpiry int64 `json:"push_expiry,omitempty"` CollapseID string `json:"collapse_id,omitempty"` }
Notification is the notification base struct.
type PGClient ¶
PGClient is the struct that connects to PostgreSQL
func NewPGClient ¶
NewPGClient creates a new client
func (*PGClient) Connect ¶
func (c *PGClient) Connect(prefix string, db interfaces.DB) error
Connect to PG
func (*PGClient) IsConnected ¶
IsConnected determines if the client is connected to PG
func (*PGClient) WaitForConnection ¶
WaitForConnection loops until PG is connected
type ParsedTopic ¶
ParsedTopic contains game and platform extracted from topic name
func GetGameAndPlatformFromTopic ¶
func GetGameAndPlatformFromTopic(topic string) ParsedTopic
GetGameAndPlatformFromTopic returns the game and plaform specified in the Kafka topic
type StatsD ¶ added in v0.2.0
type StatsD struct { Client interfaces.StatsDClient Config *viper.Viper Logger *logrus.Logger }
StatsD for sending metrics
func NewStatsD ¶ added in v0.2.0
func NewStatsD(config *viper.Viper, logger *logrus.Logger, clientOrNil ...interfaces.StatsDClient) (*StatsD, error)
NewStatsD for creating a new StatsD instance
func (*StatsD) HandleNotificationFailure ¶ added in v0.2.0
HandleNotificationFailure stores each type of failure
func (*StatsD) HandleNotificationSent ¶ added in v0.2.0
HandleNotificationSent stores notification count in StatsD
func (*StatsD) HandleNotificationSuccess ¶ added in v0.2.0
HandleNotificationSuccess stores notifications success in StatsD
func (*StatsD) InitializeFailure ¶
InitializeFailure notifu error when is impossible tho initilizer an app
func (*StatsD) ReportGoStats ¶ added in v0.2.0
func (s *StatsD) ReportGoStats( numGoRoutines int, allocatedAndNotFreed, heapObjects, nextGCBytes, pauseGCNano uint64, )
ReportGoStats reports go stats in statsd
func (*StatsD) ReportMetricCount ¶
ReportMetricCount reports a metric as a Count with hostname, game and platform as tags
type TimeoutHeap ¶ added in v1.1.0
type TimeoutHeap []*timeoutNode
TimeoutHeap is a array of timeoutNode, which has request ID and expiration time
func NewTimeoutHeap ¶ added in v1.1.0
func NewTimeoutHeap(config *viper.Viper) *TimeoutHeap
NewTimeoutHeap creates and returns a new TimeoutHeap
func (*TimeoutHeap) AddRequest ¶ added in v1.1.0
func (th *TimeoutHeap) AddRequest(deviceToken string)
AddRequest pushes new request
func (*TimeoutHeap) HasExpiredRequest ¶ added in v1.1.0
func (th *TimeoutHeap) HasExpiredRequest() (string, bool)
HasExpiredRequest removes expired request, if any
func (TimeoutHeap) Len ¶ added in v1.1.0
func (th TimeoutHeap) Len() int
Len returns the length of the heap
func (TimeoutHeap) Less ¶ added in v1.1.0
func (th TimeoutHeap) Less(i, j int) bool
Less returns true if request at index i expires before request at index j
func (*TimeoutHeap) Pop ¶ added in v1.1.0
func (th *TimeoutHeap) Pop() interface{}
Pop pops the device token of the next request that expires
func (*TimeoutHeap) Push ¶ added in v1.1.0
func (th *TimeoutHeap) Push(x interface{})
Push receives device token string and pushes it to heap
func (TimeoutHeap) Swap ¶ added in v1.1.0
func (th TimeoutHeap) Swap(i, j int)
Swap swaps requests at index i and j