风险监控Go语言SDK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
risk-sdk-go/client.go

39 lines
834 B

2 years ago
package risk
import "context"
type API interface {
WriteLog(ctx context.Context, data *LogData) error
SyncDatabase(ctx context.Context, data []*SyncData) error
}
type Client struct {
opts clientOptions
apis API
}
// NewClient 创建一个客户端
func NewClient(opt ...ClientOption) *Client {
opts := defaultClientOptions
for _, o := range opt {
o(&opts)
}
apis := NewApi(opts)
return &Client{
opts: opts,
apis: apis,
}
}
// SyncDatabase 写入访问日志,访问/v1/metric/counter/write/v2接口
func (cli *Client) WriteLog(ctx context.Context, data *LogData) error {
return cli.apis.WriteLog(ctx, data)
}
// SyncDatabase 同步数据库数据,访问/v1/config/database/sync接口
func (cli *Client) SyncDatabase(ctx context.Context, data []*SyncData) error {
return cli.apis.SyncDatabase(ctx, data)
}