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

Function versionCheckTask

pkg/component/version_check.go:32–61  ·  view source on GitHub ↗

versionCheckTask returns the task configuration for a periodic version check.

(ctx context.Context, clientProvider httpclient.Provider)

Source from the content-addressed store, hash-verified

30
31// versionCheckTask returns the task configuration for a periodic version check.
32func versionCheckTask(ctx context.Context, clientProvider httpclient.Provider) *task.Config {
33 taskConfig := task.Config{
34 Context: ctx,
35 ID: "version_check",
36 Func: func(ctx context.Context) error {
37 checkCtx, cancel := context.WithTimeout(ctx, versionCheckTimeout)
38 defer cancel()
39
40 client, err := clientProvider.HTTPClient(checkCtx)
41 if err != nil {
42 return err
43 }
44 update, err := version.CheckUpdate(checkCtx, version.WithClient(client))
45 if err != nil {
46 return err
47 }
48 version.LogUpdate(checkCtx, update)
49
50 select {
51 case <-ctx.Done():
52 return ctx.Err()
53 case <-time.After(versionCheckPeriod):
54 return nil
55 }
56 },
57 Restart: task.RestartAlways,
58 Backoff: task.DialBackoffConfig,
59 }
60 return &taskConfig
61}

Callers 1

NewFunction · 0.85

Calls 7

CheckUpdateFunction · 0.92
WithClientFunction · 0.92
LogUpdateFunction · 0.92
DoneMethod · 0.80
AfterMethod · 0.80
HTTPClientMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected