http_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: 13 Imported by: 0

Documentation

Overview

Package http_api implements a client for the new APNs HTTP/2 API (over an encrypted HTTP/2 connection to APNs)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequestProcessor

func NewRequestProcessor() common.PushRequestProcessor

NewRequestProcessor returns a new HTTPPushProcessor using net/http DefaultClient connection pool

Types

type APNSErrorResponse

type APNSErrorResponse struct {
	Reason string
	// Unix timestamp. might be in milliseconds. Not used yet.
	Timestamp int64
}

APNSErrorResponse is struct to represent JSON data returned by APNs HTTP API if push request is not successful

type ClientFactory

type ClientFactory func(*http.Transport) HTTPClient

ClientFactory is an abstraction to create HTTPClient instances (one for each push service provider). The value is overridden for testing.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is a mockable interface for the parts of http.Client used by the APNs HTTP2 module. The underlying implementation contains a connection pool, to tolerate spurious network errors.

type HTTPPushRequestProcessor

type HTTPPushRequestProcessor struct {
	// contains filtered or unexported fields
}

HTTPPushRequestProcessor sends push notification requests to APNs using HTTP API

func (*HTTPPushRequestProcessor) AddRequest

func (prp *HTTPPushRequestProcessor) AddRequest(request *common.PushRequest)

AddRequest will asynchronously process the request to send a push notification to APNs over HTTP/2

func (*HTTPPushRequestProcessor) Finalize

func (prp *HTTPPushRequestProcessor) Finalize()

Finalize will shut down all of the connections owned by HTTP/2 clients for each PSP.

func (*HTTPPushRequestProcessor) GetClient

GetClient will return the only HTTP client instance for the given psp. That instance uses the credentials and endpoint associated with the given psp.

func (*HTTPPushRequestProcessor) GetMaxPayloadSize

func (prp *HTTPPushRequestProcessor) GetMaxPayloadSize() int

GetMaxPayloadSize will return the max JSON payload size for HTTP/2 pushes (which is larger than the binary API)

func (*HTTPPushRequestProcessor) SetErrorReportChan

func (prp *HTTPPushRequestProcessor) SetErrorReportChan(errChan chan<- push.Error)

SetErrorReportChan will set the report chan used for asynchronous feedback that is not associated with a request. (not needed when using APNs's HTTP/2 API, but needed for the binary API)

func (*HTTPPushRequestProcessor) SetPushServiceConfig

func (prp *HTTPPushRequestProcessor) SetPushServiceConfig(c *push.PushServiceConfig)

SetPushServiceConfig is called during initialization to provide the unserialized contents of uniqush.conf. (does nothing for cloud messaging)

func (*HTTPPushRequestProcessor) TryGetClient

func (prp *HTTPPushRequestProcessor) TryGetClient(pspName string) HTTPClient

TryGetClient will

Directories

Path Synopsis
Package mocks implements mocks for unit testing APNs and the HTTP/2 API.
Package mocks implements mocks for unit testing APNs and the HTTP/2 API.

Jump to

Keyboard shortcuts

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