pub

package
v0.0.0-...-3d0adf2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : client.go # Created : 2019/1/16 19:19 # Last Modified : 2019/1/16 19:19 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : interface.go # Created : 2019/1/16 16:54 # Last Modified : 2019/1/16 16:54 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : public.go # Created : 2019/1/16 17:20 # Last Modified : 2019/1/16 17:20 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : send.go # Created : 2019/1/18 14:20 # Last Modified : 2019/1/18 14:20 # Describe : # # ====================================================

Index

Constants

View Source
const (
	TryNum = 3
)

Variables

View Source
var (
	// 消息已经被处理
	ErrMsgHasDealed = errors.New("msg has been dealed")
	// 重试多次后仍然失败
	ErrTooManyTimes = errors.New("retry for many times, still failed")
	// 消息已过期
	ErrMsgIsExpiration = errors.New("msg is expiration")
	// 消息发送时间未到
	ErrMsgDeliveryNotArrived = errors.New("the msg delivery time has not arrived")

	ErrMsgSendFailed = errors.New("msg send failed")

	DefaultExpirationTime = time.Minute * 15
)

Functions

func Check

func Check(id string, msg Messager) error

Check 检查数据是否有效

func EmailClient

func EmailClient(s meta.Server) send.Sender

EmailClient 根据服务商获取email客户端发送邮件

func Init

func Init()

func Send

func Send(id string, sendFunc RetryFunc) error

Send 发送消息到客户端,有重试机制,重试次数根据retryFunc里判断

func SmsClient

func SmsClient(s meta.Server) send.Sender

SmsClient 根据服务商获取sms客户端发送消息

func WeChatClient

func WeChatClient() send.Sender

WeChatClient 获取微信客户端

Types

type Cache

type Cache interface {
	RPush(context.Context, []byte) error
}

type Messager

type Messager interface {
	GetId() string
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	GetStatus() meta.Status
	SetStatus(meta.Status)
	SetTryNum(int32)
	SetResult(meta.Result)
	SetReason(string)
	GetSendTime() string
	SetUpdatedAt(string)
	GetVersion() int32
	SetVersion(int32)
}

type RetryFunc

type RetryFunc func(count int) error

func SendRetryFunc

func SendRetryFunc(msg Messager, send func(Messager) error) RetryFunc

SendRetryFunc 返回一个可以用于重试发送的方法

Jump to

Keyboard shortcuts

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