forked from aliyun/aliyun-tablestore-go-sdk
/
tunnel.go
72 lines (57 loc) · 2.7 KB
/
tunnel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package tunnel
type TunnelClient interface {
TunnelMetaApi
NewTunnelWorker(tunnelId string, workerConfig *TunnelWorkerConfig) (TunnelWorker, error)
}
type DefaultTunnelClient struct {
api *TunnelApi
}
func NewTunnelClient(endpoint, instanceName, accessId, accessKey string, options ...ClientOption) TunnelClient {
return NewTunnelClientWithConfig(endpoint, instanceName, accessId, accessKey, nil, options...)
}
func NewTunnelClientWithConfig(endpoint, instanceName, accessId, accessKey string, conf *TunnelConfig, options ...ClientOption) TunnelClient {
return &DefaultTunnelClient{
api: NewTunnelApi(endpoint, instanceName, accessId, accessKey, conf, options...),
}
}
func NewTunnelClientWithToken(endpoint, instanceName, accessId, accessKey, token string, conf *TunnelConfig, options ...ClientOption) TunnelClient {
return &DefaultTunnelClient{
api: NewTunnelApiWithToken(endpoint, instanceName, accessId, accessKey, token, conf, options...),
}
}
func NewTunnelClientWithExternalHeader(endpoint, instanceName, accessId, accessKey, token string, header map[string]string) TunnelClient {
return NewTunnelClientWithConfigAndExternalHeader(endpoint, instanceName, accessId, accessKey, token, nil, header)
}
func NewTunnelClientWithConfigAndExternalHeader(endpoint, instanceName, accessId, accessKey, token string, conf *TunnelConfig, header map[string]string) TunnelClient {
return &DefaultTunnelClient{
api: NewTunnelApiWithExternalHeader(endpoint, instanceName, accessId, accessKey, token, conf, header),
}
}
func (c *DefaultTunnelClient) CreateTunnel(req *CreateTunnelRequest) (*CreateTunnelResponse, error) {
return c.api.CreateTunnel(req)
}
func (c *DefaultTunnelClient) DeleteTunnel(req *DeleteTunnelRequest) (*DeleteTunnelResponse, error) {
return c.api.DeleteTunnel(req)
}
func (c *DefaultTunnelClient) ListTunnel(req *ListTunnelRequest) (*ListTunnelResponse, error) {
return c.api.ListTunnel(req)
}
func (c *DefaultTunnelClient) DescribeTunnel(req *DescribeTunnelRequest) (*DescribeTunnelResponse, error) {
return c.api.DescribeTunnel(req)
}
func (c *DefaultTunnelClient) GetRpo(req *GetRpoRequest) (*GetRpoResponse, error) {
return c.api.GetRpo(req)
}
func (c *DefaultTunnelClient) GetRpoByOffset(req *GetRpoRequest) (*GetRpoResponse, error) {
return c.api.GetRpoByOffset(req)
}
func (c *DefaultTunnelClient) Schedule(req *ScheduleRequest) (*ScheduleResponse, error) {
return c.api.Schedule(req)
}
func (c *DefaultTunnelClient) NewTunnelWorker(tunnelId string, workerConfig *TunnelWorkerConfig) (TunnelWorker, error) {
if workerConfig == nil {
return nil, &TunnelError{Code: ErrCodeClientError, Message: "TunnelWorkerConfig can not be nil"}
}
conf := *workerConfig
return newTunnelWorker(tunnelId, c.api, &conf)
}