Passed
Push — master ( 0cc65a...2c9229 )
by eval
02:27 queued 43s
created

athena/client.go   A

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 30
dl 0
loc 58
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A athena.*Athena.Infof 0 2 1
A athena.*Athena.GetClient 0 2 1
A athena.New 0 15 3
A athena.*Athena.Errorf 0 2 1
A athena.*Athena.SetLogger 0 2 1
1
package athena
2
3
import (
4
	SDK "github.com/aws/aws-sdk-go-v2/service/athena"
5
6
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/config"
7
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/errors"
8
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/log"
9
)
10
11
const (
12
	serviceName = "athena"
13
)
14
15
// Athena has Athena client.
16
type Athena struct {
17
	client *SDK.Client
18
19
	logger  log.Logger
20
	errWrap func(errors.ErrorData) error
21
}
22
23
// New returns initialized *Athena.
24
func New(conf config.Config) (*Athena, error) {
25
	c, err := conf.AWSConfig()
26
	if err != nil {
27
		return nil, err
28
	}
29
	if conf.Endpoints.HasAthena() {
30
		c.EndpointResolver = conf.Endpoints.GetAthena()
31
	}
32
33
	svc := &Athena{
34
		client:  SDK.New(c),
35
		logger:  conf.GetLogger(),
36
		errWrap: conf.GetErrWrap(),
37
	}
38
	return svc, nil
39
}
40
41
// GetClient gets original SDK client.
42
func (svc *Athena) GetClient() *SDK.Client {
43
	return svc.client
44
}
45
46
// SetLogger sets logger.
47
func (svc *Athena) SetLogger(logger log.Logger) {
48
	svc.logger = logger
49
}
50
51
// Infof logging information.
52
func (svc *Athena) Infof(format string, v ...interface{}) {
53
	svc.logger.Infof(serviceName, format, v...)
54
}
55
56
// Errorf logging error information.
57
func (svc *Athena) Errorf(format string, v ...interface{}) {
58
	svc.logger.Errorf(serviceName, format, v...)
0 ignored issues
show
introduced by
no formatting directive in Errorf call
Loading history...
59
}
60