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

Function New

coderd/updatecheck/updatecheck.go:61–90  ·  view source on GitHub ↗

New returns a new Checker that periodically checks for Coder updates.

(db database.Store, log slog.Logger, opts Options)

Source from the content-addressed store, hash-verified

59
60// New returns a new Checker that periodically checks for Coder updates.
61func New(db database.Store, log slog.Logger, opts Options) *Checker {
62 if opts.Client == nil {
63 opts.Client = http.DefaultClient
64 }
65 if opts.URL == "" {
66 opts.URL = defaultURL
67 }
68 if opts.Interval == 0 {
69 opts.Interval = 24 * time.Hour
70 }
71 if opts.UpdateTimeout == 0 {
72 opts.UpdateTimeout = 30 * time.Second
73 }
74 if opts.Notify == nil {
75 opts.Notify = func(_ Result) {}
76 }
77
78 ctx, cancel := context.WithCancel(context.Background())
79 c := &Checker{
80 ctx: ctx,
81 cancel: cancel,
82 db: db,
83 log: log,
84 opts: opts,
85 firstCheck: make(chan struct{}),
86 closed: make(chan struct{}),
87 }
88 go c.start()
89 return c
90}
91
92// Result is the result from the last update check.
93type Result struct {

Callers 3

NewFunction · 0.92
TestChecker_NotifyFunction · 0.92
TestChecker_LatestFunction · 0.92

Calls 1

startMethod · 0.95

Tested by 2

TestChecker_NotifyFunction · 0.74
TestChecker_LatestFunction · 0.74