model

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DummyEntry = &LogEntry{Hint: "Dummy"}
)

Functions

This section is empty.

Types

type APNsConfig

type APNsConfig struct {
	ID      int    `json:"-"`
	AuthKey string `json:"authKey" copier:"must,nopanic"`
	KeyID   string `json:"keyID" copier:"must,nopanic"`
	TeamID  string `json:"teamID" copier:"must,nopanic"`
}

func (*APNsConfig) AppId

func (c *APNsConfig) AppId() int

func (*APNsConfig) PusherType

func (c *APNsConfig) PusherType() PusherType

type App

type App struct {
	ID             int    `json:"appId" bson:"appId" copier:"AppId"`
	AppVersion     string `json:"appVersion,omitempty" bson:"appVersion"`
	PushSdkVersion string `json:"pushSdkVersion,omitempty" bson:"pushSdkVersion"`
	Language       string `json:"language,omitempty" bson:"language"`
}

func (*App) Equal

func (l *App) Equal(r *App) bool

type AppConfig

type AppConfig struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type BroadcastTask

type BroadcastTask struct {
	ID     int        `json:"id"`
	AppId  int        `json:"appId"`
	Pusher PusherType `json:"pusher"`
	Qos    Qos        `json:"qos"`
	*PushTaskMeta
	*Message
}

func AsBroadcastTask

func AsBroadcastTask(t PushTask) *BroadcastTask

check type before use this

func (*BroadcastTask) GetAppId

func (t *BroadcastTask) GetAppId() int

func (*BroadcastTask) GetID

func (t *BroadcastTask) GetID() int

func (*BroadcastTask) GetLogMeta

func (t *BroadcastTask) GetLogMeta() *LogMeta

func (*BroadcastTask) GetMessage

func (t *BroadcastTask) GetMessage() *Message

func (*BroadcastTask) GetMeta

func (t *BroadcastTask) GetMeta() *PushTaskMeta

func (*BroadcastTask) GetPusher

func (t *BroadcastTask) GetPusher() PusherType

func (*BroadcastTask) GetQos

func (t *BroadcastTask) GetQos() Qos

func (*BroadcastTask) GetType

func (t *BroadcastTask) GetType() PushTaskType

type Device

type Device struct {
	ID     string `json:"deviceId" bson:"_id" copier:"DeviceId"`
	Os     string `json:"os,omitempty" bson:"os"`
	Brand  string `json:"brand,omitempty" bson:"brand"`
	Model  string `json:"model,omitempty" bson:"model"`
	TzName string `json:"tzName,omitempty" bson:"tzName"`

	InAppPushStatus    PushStatus            `json:"inAppPushStatus,omitempty" bson:"inAppPushStatus"`
	SystemPushStatus   PushStatus            `json:"systemPushStatus,omitempty" bson:"systemPushStatus"`
	PrivacyPushStatus  PushStatus            `json:"privacyPushStatus,omitempty" bson:"privacyPushStatus"`
	BusinessPushStatus map[string]PushStatus `json:"businessPushStatus,omitempty" bson:"businessPushStatus"`

	CreateTime      time.Time `json:"createTime,omitempty" bson:"createTime"`
	LastActiveTime  time.Time `json:"lastActiveTime,omitempty" bson:"lastActiveTime"`
	TokenUpdateTime time.Time `json:"tokenUpdateTime,omitempty" bson:"tokenUpdateTime"`
	InfoUpdateTime  time.Time `json:"infoUpdateTime,omitempty" bson:"infoUpdateTime"`
}

func (*Device) Equal

func (l *Device) Equal(r *Device) bool

type DirectPushTask

type DirectPushTask struct {
	ID     int        `json:"id"`
	Pusher PusherType `json:"pusher"`
	Qos    Qos        `json:"qos"`
	*PushTaskMeta
	*Target
	*Message
}

func AsDirectPush

func AsDirectPush(t PushTask) *DirectPushTask

check type before use this

func (*DirectPushTask) GetAppId

func (t *DirectPushTask) GetAppId() int

func (*DirectPushTask) GetID

func (t *DirectPushTask) GetID() int

func (*DirectPushTask) GetLogMeta

func (t *DirectPushTask) GetLogMeta() *LogMeta

func (*DirectPushTask) GetMessage

func (t *DirectPushTask) GetMessage() *Message

func (*DirectPushTask) GetMeta

func (t *DirectPushTask) GetMeta() *PushTaskMeta

func (*DirectPushTask) GetPusher

func (t *DirectPushTask) GetPusher() PusherType

func (*DirectPushTask) GetQos

func (t *DirectPushTask) GetQos() Qos

func (*DirectPushTask) GetType

func (t *DirectPushTask) GetType() PushTaskType

type FCMConfig

type FCMConfig struct {
	ID  int    `json:"-"`
	Key string `json:"key" copier:"must,nopanic"`
}

func (*FCMConfig) AppId

func (c *FCMConfig) AppId() int

func (*FCMConfig) PusherType

func (c *FCMConfig) PusherType() PusherType

type LogBase

type LogBase struct {
	Meta  *LogMeta `json:"-"`
	T     int64    `json:"ts"`
	Where string   `json:"w"`
}

func NewLogBase

func NewLogBase(meta *LogMeta, where string) *LogBase

func (*LogBase) Timestamp

func (l *LogBase) Timestamp() int64

type LogEntry

type LogEntry struct {
	*LogBase
	Hint string `json:"h"`
}

func (*LogEntry) Decode

func (l *LogEntry) Decode(s string) error

func (*LogEntry) Encode

func (l *LogEntry) Encode() (string, error)

func (*LogEntry) Readable

func (l *LogEntry) Readable() string

func (*LogEntry) Status

func (l *LogEntry) Status() string

type LogMeta

type LogMeta struct {
	TaskId   int
	AppId    int
	DeviceId string
}

To make the length of raw log shorter, we make each tag shorter

func (*LogMeta) EntryKey

func (b *LogMeta) EntryKey() string

func (*LogMeta) PushKey

func (b *LogMeta) PushKey() string

func (*LogMeta) TaskStatusKey

func (b *LogMeta) TaskStatusKey() string

type MQTTConfig

type MQTTConfig struct {
	ID             int    `json:"-"`
	PusherKey      string `json:"pusherKey" copier:"must,nopanic"`
	PusherSecret   string `json:"pusherSecret" copier:"must,nopanic"`
	ReceiverKey    string `json:"receiverKey" copier:"must,nopanic"`
	ReceiverSecret string `json:"receiverSecret" copier:"must,nopanic"`
}

func (*MQTTConfig) AppId

func (c *MQTTConfig) AppId() int

func (*MQTTConfig) PusherType

func (c *MQTTConfig) PusherType() PusherType

type Message

type Message struct {
	Title   string `json:"title" copier:"must,nopanic"`
	Content string `json:"content" copier:"must,nopanic"`
}

type PushLogEvent

type PushLogEvent struct {
	Ctx   context.Context
	Entry *LogEntry
}

func (*PushLogEvent) GetCtx

func (e *PushLogEvent) GetCtx() context.Context

func (*PushLogEvent) GetEntry

func (e *PushLogEvent) GetEntry() *LogEntry

type PushStatus

type PushStatus = int8
const (
	Pushable   PushStatus = 1
	UnPushable PushStatus = 2
)

type PushTask

type PushTask interface {
	GetID() int
	GetType() PushTaskType
	GetAppId() int
	GetPusher() PusherType
	GetMessage() *Message
	GetLogMeta() *LogMeta
	GetMeta() *PushTaskMeta
	GetStatus() PushTaskStatusType
	GetQos() Qos

	CanRetry() bool
}

type PushTaskEvent

type PushTaskEvent struct {
	Ctx  context.Context
	Task PushTask
}

func (*PushTaskEvent) GetCtx

func (e *PushTaskEvent) GetCtx() context.Context

func (*PushTaskEvent) GetTask

func (e *PushTaskEvent) GetTask() PushTask

type PushTaskMeta

type PushTaskMeta struct {
	*RetryCounter
	Status       PushTaskStatusType `json:"status"`
	CreationTime time.Time          `json:"creationTime"`
	HandleTime   time.Time          `json:"handleTime"`
	EndTime      time.Time          `json:"endTime"`
}

func NewTaskMeta

func NewTaskMeta() *PushTaskMeta

func (*PushTaskMeta) Failure

func (m *PushTaskMeta) Failure() bool

func (*PushTaskMeta) GetCreationTime

func (m *PushTaskMeta) GetCreationTime() time.Time

func (*PushTaskMeta) GetEndTime

func (m *PushTaskMeta) GetEndTime() time.Time

func (*PushTaskMeta) GetHandleTime

func (m *PushTaskMeta) GetHandleTime() time.Time

func (*PushTaskMeta) GetStatus

func (m *PushTaskMeta) GetStatus() PushTaskStatusType

func (*PushTaskMeta) HandleDuration

func (m *PushTaskMeta) HandleDuration() time.Duration

func (*PushTaskMeta) IsDone

func (m *PushTaskMeta) IsDone() bool

func (*PushTaskMeta) IsRetry

func (m *PushTaskMeta) IsRetry() bool

func (*PushTaskMeta) OnHandle

func (m *PushTaskMeta) OnHandle() bool

func (*PushTaskMeta) SetCreationTime

func (m *PushTaskMeta) SetCreationTime(t time.Time)

func (*PushTaskMeta) SetEndTime

func (m *PushTaskMeta) SetEndTime(t time.Time)

func (*PushTaskMeta) SetFailure

func (m *PushTaskMeta) SetFailure()

func (*PushTaskMeta) SetHandleTime

func (m *PushTaskMeta) SetHandleTime(t time.Time)

func (*PushTaskMeta) SetOnHandle

func (m *PushTaskMeta) SetOnHandle()

func (*PushTaskMeta) SetRetry

func (m *PushTaskMeta) SetRetry()

func (*PushTaskMeta) SetSuccess

func (m *PushTaskMeta) SetSuccess()

func (*PushTaskMeta) Success

func (m *PushTaskMeta) Success() bool

func (*PushTaskMeta) TotalDuration

func (m *PushTaskMeta) TotalDuration() time.Duration

func (*PushTaskMeta) ValidationDuration

func (m *PushTaskMeta) ValidationDuration() time.Duration

type PushTaskStatusType

type PushTaskStatusType int8
const (
	OnHandle PushTaskStatusType = 1
	Retry    PushTaskStatusType = 2
	Success  PushTaskStatusType = 3
	Failure  PushTaskStatusType = 4
)

type PushTaskType

type PushTaskType int8
const (
	DirectPush    PushTaskType = 1
	BroadcastPush PushTaskType = 2
)

func ParsePushTaskType

func ParsePushTaskType(name string) (PushTaskType, error)

func (PushTaskType) Name

func (t PushTaskType) Name() string

func (PushTaskType) TopicNamePrefix

func (t PushTaskType) TopicNamePrefix() string

type PusherConfig

type PusherConfig interface {
	AppId() int
	PusherType() PusherType
}

func NewEmptyPusherConfig

func NewEmptyPusherConfig(appId int, t PusherType) PusherConfig

type PusherType

type PusherType int8
const (
	MQTTPusher PusherType = 1
	FCMPusher  PusherType = 2
	APNsPusher PusherType = 3
)

func ParsePusherType

func ParsePusherType(name string) (PusherType, error)

func (PusherType) Name

func (t PusherType) Name() string

type Qos

type Qos = byte
const (
	AtMostOnce  Qos = 0
	AtLeastOnce Qos = 1
	ExactlyOnce Qos = 2
)

func ParseQos

func ParseQos(s string) (Qos, error)

type RetryCounter

type RetryCounter struct {
	Counter RetryTimes `json:"retryCounter"`
}

func (*RetryCounter) CanRetry

func (c *RetryCounter) CanRetry() bool

type RetryTimes

type RetryTimes int
const (
	AlwaysRetry RetryTimes = -1
	NeverRetry  RetryTimes = 0
)

type Target

type Target struct {
	*Device `bson:"inline"`
	*App    `bson:"inline"`
	Tokens  *TokenSet `json:"tokens" bson:"tokens"`
}

func (*Target) Equal

func (l *Target) Equal(r *Target) bool

type TokenSet

type TokenSet struct {
	Self string `json:"self" bson:"self"`
}

func (*TokenSet) Equal

func (l *TokenSet) Equal(r *TokenSet) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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