NewSessionManager creates a new session manager.
(ctx context.Context, sources config.Sources, sessionStore session.Store, refreshInterval time.Duration, runConfig *config.RuntimeConfig)
| 89 | |
| 90 | // NewSessionManager creates a new session manager. |
| 91 | func NewSessionManager(ctx context.Context, sources config.Sources, sessionStore session.Store, refreshInterval time.Duration, runConfig *config.RuntimeConfig) *SessionManager { |
| 92 | loaders := make(config.Sources) |
| 93 | for name, source := range sources { |
| 94 | loaders[name] = newSourceLoader(ctx, source, refreshInterval) |
| 95 | } |
| 96 | |
| 97 | sm := &SessionManager{ |
| 98 | runtimeSessions: concurrent.NewMap[string, *activeRuntimes](), |
| 99 | deletedSessions: concurrent.NewMap[string, *activeRuntimes](), |
| 100 | eventLogs: concurrent.NewMap[string, *pumpedEventLog](), |
| 101 | followUpInjectors: concurrent.NewMap[string, FollowUpInjector](), |
| 102 | followUpKeys: concurrent.NewMap[string, *idempotencyCache](), |
| 103 | sessionStore: sessionStore, |
| 104 | Sources: loaders, |
| 105 | refreshInterval: refreshInterval, |
| 106 | runConfig: runConfig, |
| 107 | sessionReady: make(chan struct{}), |
| 108 | } |
| 109 | |
| 110 | return sm |
| 111 | } |
| 112 | |
| 113 | func (sm *SessionManager) markReady() { |
| 114 | sm.sessionReadyOnce.Do(func() { close(sm.sessionReady) }) |