MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / initRights

Method initRights

pkg/component/rights.go:25–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func (c *Component) initRights() {
26 fetcher := rights.NewAccessFetcher(func(ctx context.Context) *grpc.ClientConn {
27 conn, err := c.GetPeerConn(ctx, ttnpb.ClusterRole_ACCESS, nil)
28 if err != nil {
29 return nil
30 }
31 return conn
32 }, c.config.GRPC.AllowInsecureForCredentials)
33
34 if c.config.Rights.TTL > 0 {
35 fetcher = rights.NewInMemoryCache(fetcher, c.config.Rights.TTL, c.config.Rights.TTL)
36 } else {
37 c.Logger().Warn("No rights TTL configured")
38 }
39
40 c.rightsFetcher = fetcher
41 c.AddContextFiller(func(ctx context.Context) context.Context {
42 return rights.NewContextWithFetcher(ctx, fetcher)
43 })
44}

Callers 1

NewFunction · 0.80

Implementers 1

Componentpkg/component/component.go

Calls 7

GetPeerConnMethod · 0.95
LoggerMethod · 0.95
AddContextFillerMethod · 0.95
NewAccessFetcherFunction · 0.92
NewInMemoryCacheFunction · 0.92
NewContextWithFetcherFunction · 0.92
WarnMethod · 0.65

Tested by

no test coverage detected