Skip to content

Commit

Permalink
Subscribe automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Oct 17, 2023
1 parent 752624c commit 6dcea67
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion cmd/httpsubs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func main() {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
go subscriber.Subscribe()

c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
Expand Down
6 changes: 4 additions & 2 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ func NewHTTPSubscriber(remoteURL, localFile string, interval time.Duration) (*HT
return nil, err
}

go sub.subscribe()

return &sub, nil
}

// Subscribe starts the subscription process.
func (s *HTTPSubscriber) Subscribe() {
// subscribe starts the subscription process.
func (s *HTTPSubscriber) subscribe() {
timer := time.NewTimer(0)

for {
Expand Down
1 change: 0 additions & 1 deletion subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func TestHTTPSubscriber(t *testing.T) {
if err != nil {
t.Fatal(err)
}
go subscriber.Subscribe()

// Allow some time for subscription to run
time.Sleep(2 * time.Second)
Expand Down

0 comments on commit 6dcea67

Please sign in to comment.