Skip to content

Commit f2e881d

Browse files
committed
Use atomic.Bool for runtime started detection
1 parent 3621942 commit f2e881d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

plugins.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (r *Runtime) pluginsLoaded() bool {
8787
continue
8888
}
8989

90-
if (pluginName == bundlePluginName || status.State == plugins.StateNotReady) && r.Started {
90+
if (pluginName == bundlePluginName || status.State == plugins.StateNotReady) && r.Started.Load() {
9191
bundles, err := r.GetBundles(timeoutCxt)
9292
if err == nil && len(bundles) > 0 {
9393
// if bundle plugin state is not ready after a reconfiguration, forcefully update plugin state if bundles are loaded.

runtime.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Runtime struct {
3535
Logger *zerolog.Logger
3636
Config *Config
3737
InterQueryCache cache.InterQueryCache
38-
Started bool
38+
Started atomic.Bool
3939

4040
pluginsManager *plugins.Manager
4141
plugins map[string]plugins.Factory
@@ -434,14 +434,14 @@ func (r *Runtime) loadPaths(paths []string) (map[string]*bundle.Bundle, error) {
434434

435435
// Start - triggers plugin manager to start all plugins.
436436
func (r *Runtime) Start(ctx context.Context) error {
437-
r.Started = true
437+
r.Started.Store(true)
438438
return r.pluginsManager.Start(ctx)
439439
}
440440

441441
// Stop - triggers plugin manager to stop all plugins.
442442
func (r *Runtime) Stop(ctx context.Context) {
443-
if r.Started {
444-
r.Started = false
443+
if r.Started.Load() {
444+
r.Started.Store(false)
445445
}
446446
r.pluginsManager.Stop(ctx) // stop plugins always.
447447
}

0 commit comments

Comments
 (0)