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 NewApnsHeadersHttp2(req *RequestGaurunNotification) *push.Headers
- func NewApnsHeadersHttp2WithToken(req *RequestGaurunNotification, t *token.Token) *push.Headers
- func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{}
- func NewApnsServiceHttp2(apnsClient APNsClient) *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 APNsClient
- 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 ( ApnsPushTypeAlert = "alert" ApnsPushTypeBackground = "background" )
View Source
const (
Version = "0.14.0"
)
Variables ¶
View Source
var ( // Toml configuration for Gaurun ConfGaurun ConfToml // push notification Queue QueueNotification chan RequestGaurunNotification // Stat for Gaurun StatGaurun StatApp // http client for APNs and GCM/FCM APNSClient APNsClient 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 NewApnsHeadersHttp2 ¶ added in v0.5.0
func NewApnsHeadersHttp2(req *RequestGaurunNotification) *push.Headers
func NewApnsHeadersHttp2WithToken ¶ added in v0.13.0
func NewApnsHeadersHttp2WithToken(req *RequestGaurunNotification, t *token.Token) *push.Headers
func NewApnsPayloadHttp2 ¶ added in v0.5.0
func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{}
func NewApnsServiceHttp2 ¶ added in v0.5.0
func NewApnsServiceHttp2(apnsClient APNsClient) *push.Service
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 APNsClient ¶ added in v0.13.0
type APNsClient struct { HTTPClient *http.Client // Token is set only for token-based provider connection trust Token *token.Token }
func NewApnsClientHttp2 ¶ added in v0.5.0
func NewApnsClientHttp2(certPath, keyPath, keyPassphrase string) (APNsClient, error)
func NewApnsClientHttp2ForToken ¶ added in v0.13.0
func NewApnsClientHttp2ForToken(authKey *ecdsa.PrivateKey, keyID, teamID string) (APNsClient, error)
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"` Identifier string `json:"identifier,omitempty"` // Android CollapseKey string `json:"collapse_key,omitempty"` DelayWhileIdle bool `json:"delay_while_idle,omitempty"` TimeToLive int `json:"time_to_live,omitempty"` Priority string `json:"priority,omitempty"` // iOS Title string `json:"title,omitempty"` Subtitle string `json:"subtitle,omitempty"` PushType string `json:"push_type,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 SectionCore struct { Port string `toml:"port"` WorkerNum int64 `toml:"workers"` QueueNum int64 `toml:"queues"` NotificationMax int64 `toml:"notification_max"` PusherMax int64 `toml:"pusher_max"` ShutdownTimeout int64 `toml:"shutdown_timeout"` Pid string `toml:"pid"` AllowsEmptyMessage bool `toml:"allows_empty_message"` }
type SectionIos ¶
type SectionIos struct { Enabled bool `toml:"enabled"` PemCertPath string `toml:"pem_cert_path"` PemKeyPath string `toml:"pem_key_path"` PemKeyPassphrase string `toml:"pem_key_passphrase"` TokenAuthKeyPath string `toml:"token_auth_key_path"` TokenAuthKeyID string `toml:"token_auth_key_id"` TokenAuthTeamID string `toml:"token_auth_team_id"` 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"` }
func (*SectionIos) IsCertificateBasedProvider ¶ added in v0.13.0
func (s *SectionIos) IsCertificateBasedProvider() bool
func (*SectionIos) IsTokenBasedProvider ¶ added in v0.13.0
func (s *SectionIos) IsTokenBasedProvider() bool
type SectionLog ¶
type StatAndroid ¶
Click to show internal directories.
Click to hide internal directories.