Skip to content

Commit

Permalink
Rework flow in package subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
shal committed Jan 15, 2020
1 parent 53cfbb2 commit e2ab388
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 33,7 @@ func Subscribe(resourceID string, last time.Time) <-chan Revision {
return revisions
}

func listenPackage(packageID string, lastModified map[string]time.Time, events chan<- interface{}) {
func listenPackage(packageID string, lastModified map[string]time.Time, events chan<- Resource) {
for {
pkg, err := DefaultClient.PackageShow(context.Background(), packageID)
if err != nil {
Expand Down Expand Up @@ -71,16 71,16 @@ func listenPackage(packageID string, lastModified map[string]time.Time, events c
}

// Notify about latest changes in the resource.
events <- resource.Revisions[0]
events <- *resource
lastModified[rid] = pkg.Resources[i].LastModified.Time
}

<-time.After(60 * time.Minute)
}
}

func SubscribePackage(packageID string, lastModified map[string]time.Time) <-chan interface{} {
events := make(chan interface{})
func SubscribePackage(packageID string, lastModified map[string]time.Time) <-chan Resource {
events := make(chan Resource)
go listenPackage(packageID, lastModified, events)
return events
}

0 comments on commit e2ab388

Please sign in to comment.