MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / New

Function New

pkg/cache/policyevalbundle/policyevalbundle.go:41–63  ·  view source on GitHub ↗

New creates a policy evaluation bundle cache with built-in TTL, bucket, and description.

(ctx context.Context, rc *natsconn.ReloadableConnection, logger log.Logger)

Source from the content-addressed store, hash-verified

39
40// New creates a policy evaluation bundle cache with built-in TTL, bucket, and description.
41func New(ctx context.Context, rc *natsconn.ReloadableConnection, logger log.Logger) (*Cache, error) {
42 opts := []cache.Option{
43 cache.WithTTL(ttl),
44 cache.WithMaxBytes(maxBytes),
45 cache.WithDescription(description),
46 }
47
48 if logger != nil {
49 opts = append(opts, cache.WithLogger(log.NewHelper(logger)))
50 }
51
52 if rc != nil {
53 opts = append(opts, cache.WithNATS(rc.Conn, bucket))
54 opts = append(opts, cache.WithReconnect(rc.Subscribe(ctx)))
55 opts = append(opts, cache.WithReplicas(rc.Replicas))
56 }
57
58 c, err := cache.New[[]byte](opts...)
59 if err != nil {
60 return nil, err
61 }
62 return &Cache{Cache: c}, nil
63}

Callers 1

wireAppFunction · 0.92

Calls 9

WithTTLFunction · 0.92
WithMaxBytesFunction · 0.92
WithDescriptionFunction · 0.92
WithLoggerFunction · 0.92
WithNATSFunction · 0.92
WithReconnectFunction · 0.92
WithReplicasFunction · 0.92
NewFunction · 0.92
SubscribeMethod · 0.80

Tested by

no test coverage detected