mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 05:02:11 +08:00
feat: strategy
This commit is contained in:
parent
1d72e1dce0
commit
5abbcaebb8
@ -22,8 +22,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
incOne = datautil.ToPtr("+1")
|
incOne = datautil.ToPtr("+1")
|
||||||
addNum = "1"
|
addNum = "1"
|
||||||
|
defaultStrategy = strategy{
|
||||||
|
Default: 1,
|
||||||
|
IOS: 4,
|
||||||
|
St: 4,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type Resp struct {
|
type Resp struct {
|
||||||
@ -64,7 +69,14 @@ type TaskResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
TTL *int64 `json:"ttl"`
|
TTL *int64 `json:"ttl"`
|
||||||
|
Strategy strategy `json:"strategy"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type strategy struct {
|
||||||
|
Default int64 `json:"default"`
|
||||||
|
IOS int64 `json:"ios"`
|
||||||
|
St int64 `json:"st"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Audience struct {
|
type Audience struct {
|
||||||
|
|||||||
@ -145,7 +145,7 @@ func (g *Client) Auth(ctx context.Context, timeStamp int64) (token string, expir
|
|||||||
func (g *Client) GetTaskID(ctx context.Context, token string, pushReq PushReq) (string, error) {
|
func (g *Client) GetTaskID(ctx context.Context, token string, pushReq PushReq) (string, error) {
|
||||||
respTask := TaskResp{}
|
respTask := TaskResp{}
|
||||||
ttl := int64(1000 * 60 * 5)
|
ttl := int64(1000 * 60 * 5)
|
||||||
pushReq.Settings = &Settings{TTL: &ttl}
|
pushReq.Settings = &Settings{TTL: &ttl, Strategy: defaultStrategy}
|
||||||
err := g.request(ctx, taskURL, pushReq, token, &respTask)
|
err := g.request(ctx, taskURL, pushReq, token, &respTask)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errs.Wrap(err)
|
return "", errs.Wrap(err)
|
||||||
@ -205,7 +205,7 @@ func (g *Client) getTokenAndSave2Redis(ctx context.Context) (token string, err e
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *Client) GetTaskIDAndSave2Redis(ctx context.Context, token string, pushReq PushReq) (taskID string, err error) {
|
func (g *Client) GetTaskIDAndSave2Redis(ctx context.Context, token string, pushReq PushReq) (taskID string, err error) {
|
||||||
pushReq.Settings = &Settings{TTL: &g.taskIDTTL}
|
pushReq.Settings = &Settings{TTL: &g.taskIDTTL, Strategy: defaultStrategy}
|
||||||
taskID, err = g.GetTaskID(ctx, token, pushReq)
|
taskID, err = g.GetTaskID(ctx, token, pushReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user