Documentation
¶
Overview ¶
Package binary_api implements a client for the old APNs binary protocol (over an encrypted TCP socket)
Index ¶
- Constants
- type BinaryPushRequestProcessor
- func (prp *BinaryPushRequestProcessor) AddRequest(req *common.PushRequest)
- func (prp *BinaryPushRequestProcessor) Finalize()
- func (prp *BinaryPushRequestProcessor) GetMaxPayloadSize() int
- func (prp *BinaryPushRequestProcessor) SetErrorReportChan(errChan chan<- push.Error)
- func (prp *BinaryPushRequestProcessor) SetPushServiceConfig(c *push.PushServiceConfig)
- type ConnManager
- type PermanentError
- type Pool
- type TemporaryError
Constants ¶
const CloseTimeout = time.Hour
CloseTimeout is the timeout for closing inactive APNs binary API (encrypted TCP) connections. If the last push attempt exceeds this timeout, then we close the connection and open a new one before attempting a push.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryPushRequestProcessor ¶
type BinaryPushRequestProcessor struct {
// contains filtered or unexported fields
}
BinaryPushRequestProcessor contains the logic for V2 of the Binary Provider API.
func NewRequestProcessor ¶
func NewRequestProcessor(poolSize int) *BinaryPushRequestProcessor
NewRequestProcessor will instantiate a worker pool for processing push attempts, with a total of poolSize workers, each maintaining at most one active encrypted TCP connection to APNs at a time.
func (*BinaryPushRequestProcessor) AddRequest ¶
func (prp *BinaryPushRequestProcessor) AddRequest(req *common.PushRequest)
AddRequest will asynchronously send the requested pushes to the external push service.
func (*BinaryPushRequestProcessor) Finalize ¶
func (prp *BinaryPushRequestProcessor) Finalize()
Finalize will stop all workers, and return once all workers are finished and all resources used by this BinaryPushRequestProcessor are freed.
func (*BinaryPushRequestProcessor) GetMaxPayloadSize ¶
func (prp *BinaryPushRequestProcessor) GetMaxPayloadSize() int
GetMaxPayloadSize returns 2048 (2 kilobytes), the largest payload size supported by the APNs binary provider API.
func (*BinaryPushRequestProcessor) SetErrorReportChan ¶
func (prp *BinaryPushRequestProcessor) SetErrorReportChan(errChan chan<- push.Error)
SetErrorReportChan returns a channel to use for asynchronously reporting PushError to be handled by the backend (e.g. changes to delivery point credentials, etc.)
func (*BinaryPushRequestProcessor) SetPushServiceConfig ¶
func (prp *BinaryPushRequestProcessor) SetPushServiceConfig(c *push.PushServiceConfig)
SetPushServiceConfig passes in the contents of the "apns" section of the config file. This is called before attempting to send pushes.
type ConnManager ¶
type ConnManager interface { // Used to create a new connection. // It will be called if a worker needs to open a different connection // or if a new connection is being created. // The uint32 will be set to non-zero if the connection is closed NewConn() (net.Conn, <-chan bool, error) }
ConnManager abstracts creating TLS sockets to send push payloads to APNs.
type PermanentError ¶
type PermanentError struct {
Err error
}
PermanentError is returned by a worker because of an error that can't be fixed at the moment (e.g. a connection couldn't be established)
func (*PermanentError) Error ¶
func (err *PermanentError) Error() string
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a fixed-size pool of workers responsible for sending payloads to APNs.
func NewPool ¶
func NewPool(manager ConnManager, numWorkers int, maxWaitTime int) *Pool
NewPool creates a thread with numWorkers workers, which will wait until they are first needed to open a connection.
type TemporaryError ¶
TemporaryError is returned by a worker for problems that can be fixed by retrying.
func (*TemporaryError) Error ¶
func (err *TemporaryError) Error() string