Skip to content

Commit

Permalink
Merge pull request #2 from aurora-is-near/fix_linter
Browse files Browse the repository at this point in the history
Fix some linter errors
  • Loading branch information
spilin authored Dec 18, 2024
2 parents c82ebe3 + 19e9f8e commit 6491f1a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config/local.yaml
config/docker-compose.yaml
docker-compose.yaml
.DS_Store
.DS_Store
blockscout-vc
4 changes: 3 additions & 1 deletion cmd/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ func StartSidecarCmd() *cobra.Command {

// Initialize and start subscription service
sub := subscription.New(client)
sub.Subscribe(worker)
if err := sub.Subscribe(worker); err != nil {
return fmt.Errorf("failed to subscribe: %w", err)
}
defer sub.Stop()

// Wait for interrupt signal
Expand Down
1 change: 0 additions & 1 deletion internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

// Client represents a WebSocket client connection to Supabase Realtime
type Client struct {
conn *websocket.Conn
apiKey string
endpoint string
handlers map[string]func([]byte)
Expand Down
4 changes: 1 addition & 3 deletions internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ func (d *Docker) RecreateContainers(containerNames []string) error {
uniqueContainers := d.UniqueContainerNames(containerNames)

args := []string{"compose", "-f", pathToDockerCompose, "up", "-d", "--force-recreate"}
for _, containerName := range uniqueContainers {
args = append(args, containerName)
}
args = append(args, uniqueContainers...)

cmd := exec.Command("docker", args...)
cmd.Stdout = os.Stdout
Expand Down
5 changes: 4 additions & 1 deletion internal/heartbeat/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package heartbeat

import (
"blockscout-vc/internal/client"
"log"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -48,7 +49,9 @@ func (h *HeartbeatService) Start() {
for {
select {
case <-ticker.C:
sendHeartbeat(h.client.Conn)
if err := sendHeartbeat(h.client.Conn); err != nil {
log.Printf("Failed to send heartbeat: %v", err)
}
case <-h.stopChan:
ticker.Stop()
return
Expand Down
7 changes: 4 additions & 3 deletions internal/subscription/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func (s *Subscription) Subscribe(worker *worker.Worker) error {
if record.Event == "postgres_changes" {
table := viper.GetString("table")
if record.Payload.Data.Table == table {
record.HandleMessage()
if err := record.HandleMessage(); err != nil {
log.Printf("Failed to handle message: %v", err)
}
} else {
log.Printf("Unhandled table: %s", record.Payload.Data.Table)
}
Expand Down Expand Up @@ -127,9 +129,8 @@ func (s *Subscription) Subscribe(worker *worker.Worker) error {
}

// Stop closes the subscription connection
func (s *Subscription) Stop() error {
func (s *Subscription) Stop() {
s.client.Close()
return nil
}

// NewPostgresChanges creates a PostgresChanges instance from a raw message
Expand Down

0 comments on commit 6491f1a

Please sign in to comment.