(ctx context.Context)
| 89 | } |
| 90 | |
| 91 | func (s *CacheHandler) getCtxCache(ctx context.Context) cache.Cache { |
| 92 | pkgOnce.Do(func() { |
| 93 | _, _ = broker.Subscribe(context.WithoutCancel(ctx), common.TopicTreeChanges, func(ctx context.Context, publication broker.Message) error { |
| 94 | event := &tree.NodeChangeEvent{} |
| 95 | var e error |
| 96 | if ctx, e = publication.Unmarshal(ctx, event); e == nil && !event.Optimistic { |
| 97 | if event.Type == tree.NodeChangeEvent_CREATE || event.Type == tree.NodeChangeEvent_UPDATE_PATH || event.Type == tree.NodeChangeEvent_DELETE { |
| 98 | s.cacheEvent(runtime.WithServiceName(ctx, nodes.ViewsLibraryName), event) |
| 99 | } |
| 100 | } |
| 101 | return nil |
| 102 | }, broker.WithCounterName("nodes-cache")) |
| 103 | }) |
| 104 | return cache_helper.MustResolveCache(ctx, common.CacheTypeShared, syncCacheConfig) |
| 105 | } |
| 106 | |
| 107 | func (s *CacheHandler) cacheEvent(ctx context.Context, event *tree.NodeChangeEvent) { |
| 108 | log.Logger(ctx).Debug("Event received", zap.Any("e", event)) |
no test coverage detected