binary_api

package
v0.0.0-...-0805cb3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package binary_api implements a client for the old APNs binary protocol (over an encrypted TCP socket)

Index

Constants

View Source
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.

func (*Pool) Close

func (pool *Pool) Close()

Close waits for all workers to close their connections and finish executing.

func (*Pool) Push

func (pool *Pool) Push(payload []byte) error

Push will send the push payload to APNs, and respond with nil, TemporaryError, or PermanentError.

type TemporaryError

type TemporaryError struct {
	Err      error
	Endpoint net.Addr
}

TemporaryError is returned by a worker for problems that can be fixed by retrying.

func (*TemporaryError) Error

func (err *TemporaryError) Error() string

Directories

Path Synopsis
Package mocks implements a mock APNS server, for unit tests.
Package mocks implements a mock APNS server, for unit tests.

Jump to

Keyboard shortcuts

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