summaryrefslogtreecommitdiff
path: root/client/object
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-06-09 12:58:52 -0500
committercitrons <citrons@mondecitronne.com>2025-06-09 12:58:52 -0500
commitdc957f6bb77c9d89b52f22b605f79f7be110f546 (patch)
treed8956645e2926e4e649d1c8949b36c01158dfecf /client/object
parent51a671c2687b8f67768efd1de82acd33e0579e2b (diff)
replies
Diffstat (limited to 'client/object')
-rw-r--r--client/object/object.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/client/object/object.go b/client/object/object.go
index 2e0d83b..a3404cc 100644
--- a/client/object/object.go
+++ b/client/object/object.go
@@ -17,7 +17,7 @@ type cacheEntry struct {
type ObjStream interface {
Sub(id string)
- GetInfo(id string, callback func(proto.Command))
+ GetInfo(id string, callback func(*proto.Object))
Unsub(id string)
}
@@ -36,13 +36,7 @@ func (oc *ObjCache) Get(id string) *proto.Object {
func (oc *ObjCache) Fetch(id string, callback func(*proto.Object)) {
entry := oc.objects[id]
if !entry.cached {
- oc.stream.GetInfo(id, func(cmd proto.Command) {
- if cmd.Kind == "i" && len(cmd.Args) > 0 {
- callback(&cmd.Args[0])
- } else {
- callback(nil)
- }
- })
+ oc.stream.GetInfo(id, callback)
} else {
callback(&entry.o)
}
@@ -70,6 +64,10 @@ func (oc *ObjCache) Unwatch(id string) {
}
}
+func (oc *ObjCache) IsWatched(id string) bool {
+ return oc.objects[id].refCount > 0
+}
+
func (oc *ObjCache) Update(id string, new proto.Object) {
entry := oc.objects[id]
if entry.cached && new.Kind == entry.o.Kind {