MCPcopy Index your code
hub / github.com/coder/coder / fetchServiceBannerLoop

Method fetchServiceBannerLoop

agent/agent.go:1037–1060  ·  view source on GitHub ↗

fetchServiceBannerLoop fetches the service banner on an interval. It will not be fetched immediately; the expectation is that it is primed elsewhere (and must be done before the session actually starts).

(ctx context.Context, aAPI proto.DRPCAgentClient28)

Source from the content-addressed store, hash-verified

1035// not be fetched immediately; the expectation is that it is primed elsewhere
1036// (and must be done before the session actually starts).
1037func (a *agent) fetchServiceBannerLoop(ctx context.Context, aAPI proto.DRPCAgentClient28) error {
1038 ticker := time.NewTicker(a.announcementBannersRefreshInterval)
1039 defer ticker.Stop()
1040 for {
1041 select {
1042 case <-ctx.Done():
1043 return ctx.Err()
1044 case <-ticker.C:
1045 bannersProto, err := aAPI.GetAnnouncementBanners(ctx, &proto.GetAnnouncementBannersRequest{})
1046 if err != nil {
1047 if ctx.Err() != nil {
1048 return ctx.Err()
1049 }
1050 a.logger.Error(ctx, "failed to update notification banners", slog.Error(err))
1051 return err
1052 }
1053 banners := make([]codersdk.BannerConfig, 0, len(bannersProto.AnnouncementBanners))
1054 for _, bannerProto := range bannersProto.AnnouncementBanners {
1055 banners = append(banners, agentsdk.BannerConfigFromProto(bannerProto))
1056 }
1057 a.announcementBanners.Store(&banners)
1058 }
1059 }
1060}
1061
1062func (a *agent) run() (retErr error) {
1063 // This allows the agent to refresh its token if necessary.

Callers

nothing calls this directly

Calls 7

BannerConfigFromProtoFunction · 0.92
ErrMethod · 0.80
StopMethod · 0.65
DoneMethod · 0.45
ErrorMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected