Skip to content

Commit

Permalink
Merge pull request #531 from zenhack/snapshot-clienthook
Browse files Browse the repository at this point in the history
Add methods to make *ClientSnapshot implement ClientHook.
  • Loading branch information
zenhack authored Jun 26, 2023
2 parents d151ede + c26b7c2 commit 390b049
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ type ClientSnapshot struct {
hook *rc.Ref[clientHook]
}

func (cs ClientSnapshot) String() string {
if !cs.IsValid() {
return "ClientSnapshot{}"
}
return "ClientSnapshot{" + cs.hook.Value().String() + "}"
}

func (cs ClientSnapshot) IsValid() bool {
return cs.hook.IsValid()
}
Expand Down Expand Up @@ -654,6 +661,11 @@ func (cs *ClientSnapshot) Release() {
cs.hook.Release()
}

// Shutdown is an alias for Release, to implement ClientHook.
func (cs *ClientSnapshot) Shutdown() {
cs.Release()
}

func (cs *ClientSnapshot) Resolve1(ctx context.Context) error {
var err error
cs.hook, _, err = resolve1ClientHook(ctx, cs.hook)
Expand Down

0 comments on commit 390b049

Please sign in to comment.