gaurun

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlatFormIos = iota + 1
	PlatFormAndroid
)
View Source
const (
	ErrorStatusUnknown = iota
	ErrorStatusNotRegistered
	ErrorStatusMismatchSenderId
	ErrorStatusCanonicalId
)
View Source
const (
	StatusAcceptedPush  = "accepted-push"
	StatusSucceededPush = "succeeded-push"
	StatusFailedPush    = "failed-push"
)
View Source
const EpApnsProd = "gateway.push.apple.com:2195"
View Source
const EpApnsSandbox = "gateway.sandbox.push.apple.com:2195"
View Source
const Version = "0.4.0"

Variables

View Source
var (
	ConfGaurun        ConfToml
	QueueNotification chan RequestGaurunNotification
	CertificatePemIos CertificatePem
	LogAccess         *logrus.Logger
	LogError          *logrus.Logger
	StatGaurun        StatApp
	// for numbering push
	OnceNumbering   sync.Once
	WgNumbering     *sync.WaitGroup
	SeqID           uint64
	GCMClient       *gcm.Sender
	TransportGaurun *http.Transport
)

Functions

func ConfigGaurunHandler

func ConfigGaurunHandler(w http.ResponseWriter, r *http.Request)

func InitGCMClient added in v0.2.1

func InitGCMClient()

func InitLog

func InitLog() *logrus.Logger

func InitStatGaurun

func InitStatGaurun()

func LogAcceptedRequest

func LogAcceptedRequest(uri, method, proto string, length int64)

func LogPush

func LogPush(id uint64, status, token string, ptime float64, req RequestGaurunNotification, errPush error)

func PrintGaurunVersion

func PrintGaurunVersion()

func PushNotificationHandler

func PushNotificationHandler(w http.ResponseWriter, r *http.Request)

func SetLogLevel

func SetLogLevel(log *logrus.Logger, levelString string) error

func SetLogOut

func SetLogOut(log *logrus.Logger, outString string) error

func StartPushWorkers

func StartPushWorkers(workerNum, queueNum int)

func StatsGaurunHandler

func StatsGaurunHandler(w http.ResponseWriter, r *http.Request)

Types

type CertificatePem

type CertificatePem struct {
	Cert []byte
	Key  []byte
}

type ConfToml

type ConfToml struct {
	Core    SectionCore    `toml:"core"`
	Api     SectionApi     `toml:"api"`
	Android SectionAndroid `toml:"android"`
	Ios     SectionIos     `toml:"ios"`
	Log     SectionLog     `toml:"log"`
}

func BuildDefaultConfGaurun

func BuildDefaultConfGaurun() ConfToml

func LoadConfGaurun

func LoadConfGaurun(confGaurun ConfToml, confPath string) (ConfToml, error)

type ExtendJSON added in v0.3.0

type ExtendJSON struct {
	Key   string `json:"key"`
	Value string `json:"val"`
}

type GaurunFormatter

type GaurunFormatter struct {
}

func (*GaurunFormatter) Format

func (f *GaurunFormatter) Format(entry *logrus.Entry) ([]byte, error)

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
	Badge  int    `json:"badge,omitempty"`
	Sound  string `json:"sound,omitempty"`
	Expiry int    `json:"expiry,omitempty"`
}

type LogReq

type LogReq struct {
	Type          string `json:"type"`
	Time          string `json:"time"`
	URI           string `json:"uri"`
	Method        string `json:"method"`
	Proto         string `json:"proto"`
	ContentLength int64  `json:"content_length"`
}

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
	Badge  int          `json:"badge,omitempty"`
	Sound  string       `json:"sound,omitempty"`
	Expiry int          `json:"expiry,omitempty"`
	Retry  int          `json:"retry,omitempty"`
	Extend []ExtendJSON `json:"extend,omitempty"`
	// meta
	IDs []uint64 `json:"seq_id,omitempty"`
}

type ResponseGaurun

type ResponseGaurun struct {
	Message string `json:"message"`
}

type SectionAndroid

type SectionAndroid struct {
	Enabled  bool   `toml:"enabled"`
	ApiKey   string `toml:"apikey"`
	Timeout  int    `toml:"timeout"`
	RetryMax int    `toml:"retry_max"`
}

type SectionApi

type SectionApi struct {
	PushUri      string `toml:"push_uri"`
	StatGoUri    string `toml:"stat_go_uri"`
	StatAppUri   string `toml:"stat_app_uri"`
	ConfigAppUri string `toml:"config_app_uri"`
}

type SectionCore

type SectionCore struct {
	Port            string `toml:"port"`
	WorkerNum       int    `toml:"workers"`
	QueueNum        int    `toml:"queues"`
	NotificationMax int    `toml:"notification_max"`
}

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"`
	TimeoutError         int    `toml:"timeout_error"`
	KeepAliveMax         int    `toml:"keepalive_max"`
	KeepAliveIdleTimeout int    `toml:"keepalive_idle_timeout"`
}

type SectionLog

type SectionLog struct {
	AccessLog string `toml:"access_log"`
	ErrorLog  string `toml:"error_log"`
	Level     string `toml:"level"`
}

type StatAndroid

type StatAndroid struct {
	PushSuccess int64 `json:"push_success"`
	PushError   int64 `json:"push_error"`
}

type StatApp

type StatApp struct {
	QueueMax   int         `json:"queue_max"`
	QueueUsage int         `json:"queue_usage"`
	Ios        StatIos     `json:"ios"`
	Android    StatAndroid `json:"android"`
}

type StatIos

type StatIos struct {
	PushSuccess int64 `json:"push_success"`
	PushError   int64 `json:"push_error"`
}

Jump to

Keyboard shortcuts

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