完善任务接口逻辑以及Eran事件上报接入

This commit is contained in:
lianghuanjie
2024-12-13 16:15:20 +08:00
parent 9f4fb0a9d0
commit f9084a0eb3
20 changed files with 408 additions and 84 deletions

45
internal/pkg/earn/earn.go Normal file
View File

@@ -0,0 +1,45 @@
package earn
import (
ea "github.com/earn-alliance/earnalliance-go"
"time"
)
type Config struct {
ClientId string
ClientSecret string
GameId string
Dsn string `json:",optional"`
FlushCooldown time.Duration `json:",optional"`
FlushInterval time.Duration `json:",optional"`
BatchSize int `json:",optional"`
}
func (c Config) BuildEarnClient() *ea.Client {
clientBuilder := ea.NewClientBuilder().
WithClientID(c.ClientId).
WithClientSecret(c.ClientSecret).
WithGameID(c.GameId)
if c.Dsn != "" {
clientBuilder = clientBuilder.WithDSN(c.Dsn)
}
if c.FlushCooldown > 0 {
clientBuilder = clientBuilder.WithFlushCooldown(c.FlushCooldown)
}
if c.FlushInterval > 0 {
clientBuilder = clientBuilder.WithFlushInterval(c.FlushInterval)
}
if c.BatchSize > 0 {
clientBuilder = clientBuilder.WithBatchSize(c.BatchSize)
}
return clientBuilder.Build()
}
const (
EVENT_BIND_ROLE = "BIND_ROLE"
)