Skip to content

Commit 77cc49e

Browse files
committed
Linter fixes
1 parent fd35cb1 commit 77cc49e

3 files changed

Lines changed: 29 additions & 19 deletions

File tree

connections/data_source.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,28 @@ func WithRetryDelay(delay time.Duration) SourceOption {
5252
}
5353

5454
func WithPostgresDB(dbConn *gorm.DB) SourceOption {
55+
checkPointer(dbConn)
5556
return func(w *DataSource) {
5657
w.DatabasePostgres = dbConn
5758
}
5859
}
5960

6061
func WithMongoDB(dbConn *mongo.Client) SourceOption {
62+
checkPointer(dbConn)
6163
return func(w *DataSource) {
6264
w.DatabaseMongo = dbConn
6365
}
6466
}
6567

6668
func WithRosettaClient(client *client.APIClient) SourceOption {
69+
checkPointer(client)
6770
return func(w *DataSource) {
6871
w.RosettaClient = client
6972
}
7073
}
7174

7275
func WithNodeClient(node interface{}) SourceOption {
76+
checkPointer(node)
7377
return func(w *DataSource) {
7478
w.NodeClient = node
7579
}
@@ -84,3 +88,9 @@ func WithDataStore(cfg ds.DataStoreConfig) SourceOption {
8488
w.DataStore = storeClient
8589
}
8690
}
91+
92+
func checkPointer(p interface{}) {
93+
if p == nil {
94+
panic("Pointer cannot be null!")
95+
}
96+
}

connections/database/graphql/graphql.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ type GraphqlSubscriptionClient struct {
2626
connected bool
2727
}
2828

29-
func NewGraphqlQueryClient(host string, token string) GraphqlClient {
29+
func NewGraphqlQueryClient(host string, token string) *GraphqlClient {
3030
transport := http.DefaultTransport
3131
if token != "" {
3232
transport = database.AuthHeaderTransport{Transport: http.DefaultTransport, Token: token}
3333
}
3434

3535
customHttpClient := http.Client{Transport: transport}
36-
return GraphqlClient{
36+
return &GraphqlClient{
3737
Host: host,
3838
Client: graphql.NewClient(host, &customHttpClient),
3939
}
4040
}
4141

42-
func (c GraphqlClient) Connect() error {
42+
func (c *GraphqlClient) Connect() error {
4343
return nil
4444
}
4545

46-
func NewGraphqlSubscriptionClient(host string, token string) (error, GraphqlSubscriptionClient) {
46+
func NewGraphqlSubscriptionClient(host string, token string) (error, *GraphqlSubscriptionClient) {
4747
client := graphql.NewSubscriptionClient(host).
4848
WithConnectionParams(map[string]interface{}{
4949
"headers": map[string]string{
5050
"x-hasura-admin-secret": token,
5151
},
5252
}).OnError(onClientError)
5353

54-
subClient := GraphqlSubscriptionClient{
54+
subClient := &GraphqlSubscriptionClient{
5555
Client: client,
5656
errChan: make(chan error),
5757
readyChan: make(chan bool),
@@ -64,13 +64,13 @@ func NewGraphqlSubscriptionClient(host string, token string) (error, GraphqlSubs
6464
return nil, subClient
6565
}
6666

67-
func (c GraphqlSubscriptionClient) onClientConnected() {
67+
func (c *GraphqlSubscriptionClient) onClientConnected() {
6868
zap.S().Infof("Graphql client connected")
6969
c.connected = true
7070
c.readyChan <- true
7171
}
7272

73-
func (c GraphqlSubscriptionClient) onClientDisconnected() {
73+
func (c *GraphqlSubscriptionClient) onClientDisconnected() {
7474
zap.S().Warnf("Graphql client disconnected")
7575
c.connected = false
7676
c.readyChan <- false
@@ -81,7 +81,7 @@ func onClientError(sc *graphql.SubscriptionClient, err error) error {
8181
return err
8282
}
8383

84-
func (c GraphqlSubscriptionClient) Subscribe(query interface{}, handler func(message *json.RawMessage, err error) error) error {
84+
func (c *GraphqlSubscriptionClient) Subscribe(query interface{}, handler func(message *json.RawMessage, err error) error) error {
8585
id, err := c.Client.Subscribe(query, nil, handler)
8686
if err != nil {
8787
return err
@@ -90,15 +90,15 @@ func (c GraphqlSubscriptionClient) Subscribe(query interface{}, handler func(mes
9090
return nil
9191
}
9292

93-
func (c GraphqlSubscriptionClient) Unsubscribe() error {
93+
func (c *GraphqlSubscriptionClient) Unsubscribe() error {
9494
err := c.Client.Unsubscribe(c.Id)
9595
if err != nil {
9696
return err
9797
}
9898
return nil
9999
}
100100

101-
func (c GraphqlSubscriptionClient) Start() error {
101+
func (c *GraphqlSubscriptionClient) Start() error {
102102
go func() {
103103
err := c.Client.Run()
104104
if err != nil {
@@ -118,10 +118,10 @@ func (c GraphqlSubscriptionClient) Start() error {
118118
}
119119
}
120120

121-
func (c GraphqlSubscriptionClient) Stop() error {
121+
func (c *GraphqlSubscriptionClient) Stop() error {
122122
return c.Client.Close()
123123
}
124124

125-
func (c GraphqlSubscriptionClient) GetState() bool {
125+
func (c *GraphqlSubscriptionClient) GetState() bool {
126126
return c.connected
127127
}

workers/workQueue/dispatcher.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type DispatcherConfig struct {
2121
JobsTopic string
2222
}
2323

24-
func NewJobDispatcher() JobDispatcher {
24+
func NewJobDispatcher() *JobDispatcher {
2525
d := JobDispatcher{
2626
retryTimeout: DefaultRetryTimeout,
2727
jobPool: NewJobPool(),
@@ -31,14 +31,14 @@ func NewJobDispatcher() JobDispatcher {
3131
EmptyQueueChan: make(chan bool),
3232
}
3333

34-
return d
34+
return &d
3535
}
3636

37-
func (j JobDispatcher) SetRetryTimeout(timeout time.Duration) {
37+
func (j *JobDispatcher) SetRetryTimeout(timeout time.Duration) {
3838
j.retryTimeout = timeout
3939
}
4040

41-
func (j JobDispatcher) BuildWorkers(count int, constructor WorkerConstructor) {
41+
func (j *JobDispatcher) BuildWorkers(count int, constructor WorkerConstructor) {
4242
for i := 0; i < count; i++ {
4343
workerId := fmt.Sprintf("worker.%d", i)
4444
worker := constructor(workerId, j.workerChan)
@@ -47,7 +47,7 @@ func (j JobDispatcher) BuildWorkers(count int, constructor WorkerConstructor) {
4747
}
4848

4949
// TODO listen for incoming jobs on JobsTopic
50-
func (j JobDispatcher) Start() {
50+
func (j *JobDispatcher) Start() {
5151
j.dispatch()
5252
for {
5353
work := j.jobPool.GetNewJob()
@@ -62,11 +62,11 @@ func (j JobDispatcher) Start() {
6262
}
6363
}
6464

65-
func (j JobDispatcher) EnqueueWork(w Work) {
65+
func (j *JobDispatcher) EnqueueWork(w Work) {
6666
j.jobPool.EnqueueJob(w)
6767
}
6868

69-
func (j JobDispatcher) dispatch() {
69+
func (j *JobDispatcher) dispatch() {
7070
go func() {
7171
for {
7272
select {

0 commit comments

Comments
 (0)