Documentation
¶
Index ¶
- Constants
- Variables
- func InitErrorResponseHandler(erh ResponseHandler) error
- func InitSuccessResponseHandler(sh ResponseHandler) error
- func InvokePipe(hook string, src io.Reader) ([]byte, error)
- func LogWithFields(fields map[string]interface{}) *logrus.Entry
- func StartServer(conf config.Config, env Environment)
- type Client
- type Command
- type DefaultResponseHandler
- type Environment
- type LtsvFormatter
- type Notification
- type PostedData
- type Provider
- type Request
- type ResponseHandler
- type Result
- type SenderResponse
- type Stats
- type Supervisor
- type Worker
Constants ¶
const ( // SendRetryCount is the threashold which is resend count. SendRetryCount = 10 // RetryWaitTime is periodical time to retrieve notifications from retry queue to resend RetryWaitTime = time.Millisecond * 500 // RetryOnceCount is the number of sending notification at once. RetryOnceCount = 1000 // multiplicity of sending notifications. SenderNum = 20 RequestPerSec = 2000 // About the average time of response from apns. That value is not accurate // because that is defined heuristically in Japan. AverageResponseTime = time.Millisecond * 150 // Minimum RetryAfter time (seconds). RetryAfterSecond = time.Second * 10 // Gunfish returns RetryAfter header based on 'Exponential Backoff'. Therefore, // that defines the wait time threshold so as not to wait too long. ResetRetryAfterSecond = time.Second * 60 // FlowRateInterval is the designed value to enable to delivery notifications // for that value seconds. Gunfish is designed as to ensure to delivery // notifications for 10 seconds. FlowRateInterval = time.Second * 10 // Default flow rate as notification requests per sec (req/sec). DefaultFlowRatePerSec = 2000 // Wait millisecond interval when to shutdown. ShutdownWaitTime = time.Millisecond * 10 // That is the count while request counter is 0 in the 'ShutdownWaitTime' period. RestartWaitCount = 50 )
Default values
const ( DevServer = "https://api.development.push.apple.com" ProdServer = "https://api.push.apple.com" MockServer = "https://localhost:2195" )
Apns endpoints
const ( ApplicationJSON = "application/json" ApplicationXW3FormURLEncoded = "application/x-www-form-urlencoded" )
Supports Content-Type
Variables ¶
var ( OutputHookStdout bool OutputHookStderr bool )
var (
AlertKeyToField = map[string]string{
"title": "Title",
"body": "Body",
"title-loc-key": "TitleLocKey",
"title-loc-args": "TitleLocArgs",
"action-loc-key": "ActionLocKey",
"loc-key": "LocKey",
"loc-args": "LocArgs",
"launch-image": "LaunchImage",
}
)
Alert fields mapping
var RetryBackoff = true
Functions ¶
func InitErrorResponseHandler ¶
func InitErrorResponseHandler(erh ResponseHandler) error
InitErrorResponseHandler initialize error response handler.
func InitSuccessResponseHandler ¶
func InitSuccessResponseHandler(sh ResponseHandler) error
InitSuccessResponseHandler initialize success response handler.
func LogWithFields ¶
LogWithFields wraps logrus's WithFields
func StartServer ¶
func StartServer(conf config.Config, env Environment)
StartServer starts an apns provider server on http.
Types ¶
type Client ¶ added in v0.2.0
type Client interface {
Send(Notification) ([]Result, error)
}
Client interface for fcm and apns client
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command has execute command and input stream.
type DefaultResponseHandler ¶
type DefaultResponseHandler struct {
Hook string
}
DefaultResponseHandler is the default ResponseHandler if not specified.
func (DefaultResponseHandler) HookCmd ¶
func (rh DefaultResponseHandler) HookCmd() string
HookCmd returns hook command to execute after getting response from APNS only when to get error response.
func (DefaultResponseHandler) OnResponse ¶
func (rh DefaultResponseHandler) OnResponse(result Result)
OnResponse is performed when to receive result from APNs or FCM.
type Environment ¶
type Environment int
Environment struct
const ( Production Environment = iota Development Test Disable )
Executed environment
func (Environment) String ¶
func (i Environment) String() string
type LtsvFormatter ¶
LtsvFormatter is ltsv format for logrus
type Notification ¶ added in v0.2.0
type Notification interface{}
type PostedData ¶
type PostedData struct {
Header apns.Header `json:"header,omitempty"`
Token string `json:"token"`
Payload apns.Payload `json:"payload"`
}
PostedData is posted data to this provider server /push/apns.
type Provider ¶
type Provider struct {
Sup Supervisor
}
Provider defines Gunfish httpHandler and has a state of queue which is shared by the supervisor.
func (*Provider) PushAPNsHandler ¶ added in v0.3.1
func (prov *Provider) PushAPNsHandler() http.HandlerFunc
func (*Provider) PushFCMHandler ¶ added in v0.3.1
func (prov *Provider) PushFCMHandler() http.HandlerFunc
func (*Provider) StatsHandler ¶ added in v0.3.1
func (prov *Provider) StatsHandler() http.HandlerFunc
type Request ¶
type Request struct {
Notification Notification
Tries int
}
type ResponseHandler ¶
ResponseHandler provides you to implement handling on success or on error response from apns. Therefore, you can specifies hook command which is set at toml file.
type SenderResponse ¶
type SenderResponse struct {
Results []Result `json:"response"`
RespTime float64 `json:"response_time"`
Req Request `json:"request"`
Err error `json:"error_msg"`
UID string `json:"resp_uid"`
}
SenderResponse is responses to worker from sender.
type Stats ¶
type Stats struct {
Pid int `json:"pid"`
DebugPort int `json:"debug_port"`
Uptime int64 `json:"uptime"`
StartAt int64 `json:"start_at"`
Period int64 `json:"period"`
RetryAfter int64 `json:"retry_after"`
Workers int64 `json:"workers"`
QueueSize int64 `json:"queue_size"`
RetryQueueSize int64 `json:"retry_queue_size"`
WorkersQueueSize int64 `json:"workers_queue_size"`
CommandQueueSize int64 `json:"cmdq_queue_size"`
RetryCount int64 `json:"retry_count"`
RequestCount int64 `json:"req_count"`
SentCount int64 `json:"sent_count"`
ErrCount int64 `json:"err_count"`
CertificateNotAfter time.Time `json:"certificate_not_after"`
CertificateExpireUntil int64 `json:"certificate_expire_until"`
}
Stats stores metrics
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor monitor mutiple http2 clients.
func StartSupervisor ¶
func StartSupervisor(conf *config.Config) (Supervisor, error)
StartSupervisor starts supervisor
func (*Supervisor) EnqueueClientRequest ¶
func (s *Supervisor) EnqueueClientRequest(reqs *[]Request) error
EnqueueClientRequest enqueues request to supervisor's queue from external application service
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
apnsmock
command
|
|
|
gunfish
command
|
|
|
test
|
|
|
tools/apnsmock
command
|
|
|
tools/fcmv1mock
command
|
|
|
tools/gunfish-cli
command
|
