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) }