Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5da993b652 |
@ -164,3 +164,10 @@ func (c *Client) GetGamePayAmount(req *GetGamePayAmountReq) (resp *GetGamePayAmo
|
|||||||
err = c.DoAction(req, resp)
|
err = c.DoAction(req, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KafkaEvent 通用推入kafka数据
|
||||||
|
func (c *Client) KafkaEvent(req *KafkaEventReq) (resp *KafkaEventResp, err error) {
|
||||||
|
resp = CreateKafkaEventResp()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@ -378,3 +378,27 @@ func TestGetGamePayAmount(t *testing.T) {
|
|||||||
t.Errorf("GetGamePayAmount failed: code=%d msg=%s", resp.Code, resp.Msg)
|
t.Errorf("GetGamePayAmount failed: code=%d msg=%s", resp.Code, resp.Msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestKafkaEvent(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
req := CreateKafkaEventReq(map[string]any{
|
||||||
|
"topic": "test_lebian_sop_event",
|
||||||
|
"event_name": "测试数据",
|
||||||
|
"event_data": map[string]any{},
|
||||||
|
})
|
||||||
|
|
||||||
|
resp, err := client.KafkaEvent(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(resp.Code, resp.Msg)
|
||||||
|
|
||||||
|
// 成功码为 1
|
||||||
|
if resp.Code != 1 {
|
||||||
|
t.Errorf("TestKafkaEvent failed: code=%d msg=%s", resp.Code, resp.Msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
28
services/stat/event_track.go
Normal file
28
services/stat/event_track.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package stat
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type KafkaEventReq = requests.JsonRequest
|
||||||
|
|
||||||
|
type KafkaEventResp struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateKafkaEventReq(param map[string]any) *KafkaEventReq {
|
||||||
|
req := &requests.JsonRequest{}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/event_track/kafka")
|
||||||
|
req.Method = requests.POST
|
||||||
|
req.JsonParams = param
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateKafkaEventResp() *KafkaEventResp {
|
||||||
|
return &KafkaEventResp{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user