Documentation ¶
Index ¶
- Constants
- Variables
- func ApnsPushHttp2(token string, service *push.Service, headers *push.Headers, ...) error
- func ConfigPushersHandler(w http.ResponseWriter, r *http.Request)
- func InitAPNSClient() error
- func InitGCMClient() error
- func InitStat()
- func LocalTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func LogAcceptedRequest(r *http.Request)
- func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNotification, ...)
- func LogSetupFatal(err error)
- func NewApnsClientHttp2(certPath, keyPath string) (*http.Client, error)
- func NewApnsHeadersHttp2(req *RequestGaurunNotification) *push.Headers
- func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{}
- func NewApnsServiceHttp2(client *http.Client) *push.Service
- func NewTransportHttp2(cert tls.Certificate) (*http.Transport, error)
- func PrintVersion()
- func PushNotificationHandler(w http.ResponseWriter, r *http.Request)
- func RegisterHandlers(mux *http.ServeMux)
- func RunServer(server *http.Server, conf *ConfToml) error
- func StartPushWorkers(workerNum, queueNum int64)
- func StatsHandler(w http.ResponseWriter, r *http.Request)
- type CertificatePem
- type ConfToml
- type ExtendJSON
- type LogPushEntry
- type LogReq
- type Reopener
- type RequestGaurun
- type RequestGaurunNotification
- type ResponseGaurun
- type SectionAndroid
- type SectionCore
- type SectionIos
- type SectionLog
- type StatAndroid
- type StatApp
- type StatIos
Constants ¶
View Source
const ( PlatFormIos = iota + 1 PlatFormAndroid )
View Source
const ( StatusAcceptedPush = "accepted-push" StatusSucceededPush = "succeeded-push" StatusFailedPush = "failed-push" StatusDisabledPush = "disabled-push" )
View Source
const (
Version = "0.9.0"
)
Variables ¶
View Source
var ( // Toml configuration for Gaurun ConfGaurun ConfToml // push notification Queue QueueNotification chan RequestGaurunNotification // TLS certificate and key for APNs CertificatePemIos CertificatePem // Stat for Gaurun StatGaurun StatApp // http client for APNs and GCM/FCM APNSClient *http.Client GCMClient *gcm.Client // access and error logger LogAccess *zap.Logger LogError *zap.Logger // sequence ID for numbering push SeqID uint64 )
View Source
var ( // PusherCountAll is the shared value between workers PusherCountAll int64 // PusherWg is global wait group for pusher worker. // It increments when new pusher is swapned and decrements when job is done. // // This is used to block main process to shutdown while pusher is still working. PusherWg sync.WaitGroup )
Functions ¶
func ApnsPushHttp2 ¶ added in v0.5.0
func ConfigPushersHandler ¶ added in v0.7.0
func ConfigPushersHandler(w http.ResponseWriter, r *http.Request)
func InitAPNSClient ¶ added in v0.8.0
func InitAPNSClient() error
func InitGCMClient ¶ added in v0.2.1
func InitGCMClient() error
InitGCMClient initializes GCMClient which is globally declared.
func LocalTimeEncoder ¶ added in v0.8.0
func LocalTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
func LogAcceptedRequest ¶
func LogPush ¶
func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNotification, errPush error)
func LogSetupFatal ¶ added in v0.7.0
func LogSetupFatal(err error)
LogSetupFatal output error log with log package and exit immediately.
func NewApnsClientHttp2 ¶ added in v0.5.0
func NewApnsHeadersHttp2 ¶ added in v0.5.0
func NewApnsHeadersHttp2(req *RequestGaurunNotification) *push.Headers
func NewApnsPayloadHttp2 ¶ added in v0.5.0
func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{}
func NewApnsServiceHttp2 ¶ added in v0.5.0
func NewTransportHttp2 ¶ added in v0.5.1
func NewTransportHttp2(cert tls.Certificate) (*http.Transport, error)
func PrintVersion ¶ added in v0.5.1
func PrintVersion()
func PushNotificationHandler ¶
func PushNotificationHandler(w http.ResponseWriter, r *http.Request)
func RegisterHandlers ¶ added in v0.8.0
func StartPushWorkers ¶
func StartPushWorkers(workerNum, queueNum int64)
func StatsHandler ¶ added in v0.5.1
func StatsHandler(w http.ResponseWriter, r *http.Request)
Types ¶
type CertificatePem ¶
type ConfToml ¶
type ConfToml struct { Core SectionCore `toml:"core"` Android SectionAndroid `toml:"android"` Ios SectionIos `toml:"ios"` Log SectionLog `toml:"log"` }
func BuildDefaultConf ¶ added in v0.5.1
func BuildDefaultConf() ConfToml
type ExtendJSON ¶ added in v0.3.0
type LogPushEntry ¶
type LogPushEntry struct { Type string `json:"type"` Time string `json:"time"` ID uint64 `json:"id"` Platform string `json:"platform"` Token string `json:"token"` Message string `json:"message"` Ptime float64 `json:"ptime"` Error string `json:"error"` // Android CollapseKey string `json:"collapse_key,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` // iOS Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` Badge int `json:"badge,omitempty"` Category string `json:"category,omitempty"` Sound string `json:"sound,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` MutableContent bool `json:"mutable_content,omitempty"` Expiry int `json:"expiry,omitempty"` }
type RequestGaurun ¶
type RequestGaurun struct {
Notifications []RequestGaurunNotification `json:"notifications"`
}
type RequestGaurunNotification ¶
type RequestGaurunNotification struct { // Common Tokens []string `json:"token"` Platform int `json:"platform"` Message string `json:"message"` // Android CollapseKey string `json:"collapse_key,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` // iOS Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` Badge int `json:"badge,omitempty"` Category string `json:"category,omitempty"` Sound string `json:"sound,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` MutableContent bool `json:"mutable_content,omitempty"` Expiry int `json:"expiry,omitempty"` Retry int `json:"retry,omitempty"` Extend []ExtendJSON `json:"extend,omitempty"` // meta ID uint64 `json:"seq_id,omitempty"` }
type ResponseGaurun ¶
type ResponseGaurun struct {
Message string `json:"message"`
}
type SectionAndroid ¶
type SectionCore ¶
type SectionIos ¶
type SectionIos struct { Enabled bool `toml:"enabled"` PemCertPath string `toml:"pem_cert_path"` PemKeyPath string `toml:"pem_key_path"` Sandbox bool `toml:"sandbox"` RetryMax int `toml:"retry_max"` Timeout int `toml:"timeout"` KeepAliveTimeout int `toml:"keepalive_timeout"` KeepAliveConns int `toml:"keepalive_conns"` Topic string `toml:"topic"` }
type SectionLog ¶
type StatAndroid ¶
Click to show internal directories.
Click to hide internal directories.