Skip to content

Commit

Permalink
Merge pull request #34 from jortel/model5
Browse files Browse the repository at this point in the history
Disable the journal when DB closed; add DB.EndWatch().
  • Loading branch information
jortel authored Nov 23, 2020
2 parents 45cf82c + 688be41 commit 8f5dc35
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/inventory/model/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type DB interface {
Delete(Model) error
// Watch a model collection.
Watch(Model, EventHandler) (*Watch, error)
// End a watch.
EndWatch(watch *Watch)
// The journal
Journal() *Journal
}
Expand Down Expand Up @@ -97,6 +99,7 @@ func (r *Client) Close(purge bool) error {
if r.db == nil {
return nil
}
r.journal.Disable()
err := r.db.Close()
if err != nil {
return liberr.Wrap(err)
Expand Down Expand Up @@ -248,6 +251,12 @@ func (r *Client) Watch(model Model, handler EventHandler) (*Watch, error) {
return watch, nil
}

//
// End watch.
func (r *Client) EndWatch(watch *Watch) {
r.journal.End(watch)
}

//
// The associated journal.
func (r *Client) Journal() *Journal {
Expand Down

0 comments on commit 8f5dc35

Please sign in to comment.