mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 09:26:47 +00:00
fix: context
This commit is contained in:
@@ -315,7 +315,7 @@ spec:
|
|||||||
description: Infisical host to pull secrets from
|
description: Infisical host to pull secrets from
|
||||||
type: string
|
type: string
|
||||||
instantUpdates:
|
instantUpdates:
|
||||||
default: true
|
default: false
|
||||||
type: boolean
|
type: boolean
|
||||||
managedKubeConfigMapReferences:
|
managedKubeConfigMapReferences:
|
||||||
items:
|
items:
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ func (c *ConnectionMeta) Cancel() {
|
|||||||
|
|
||||||
// ConnectionRegistry manages SSE connections with high performance
|
// ConnectionRegistry manages SSE connections with high performance
|
||||||
type ConnectionRegistry struct {
|
type ConnectionRegistry struct {
|
||||||
ctx context.Context
|
|
||||||
client Client
|
client Client
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
@@ -52,7 +51,6 @@ type ConnectionRegistry struct {
|
|||||||
// NewConnectionRegistry creates a new high-performance connection registry
|
// NewConnectionRegistry creates a new high-performance connection registry
|
||||||
func NewConnectionRegistry(ctx context.Context) *ConnectionRegistry {
|
func NewConnectionRegistry(ctx context.Context) *ConnectionRegistry {
|
||||||
r := &ConnectionRegistry{
|
r := &ConnectionRegistry{
|
||||||
ctx: ctx,
|
|
||||||
monitorStop: make(chan struct{}),
|
monitorStop: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +146,7 @@ func (r *ConnectionRegistry) getConnection() *ConnectionMeta {
|
|||||||
|
|
||||||
// createConnection creates a new SSE connection
|
// createConnection creates a new SSE connection
|
||||||
func (r *ConnectionRegistry) createConnection(req *http.Request) (*ConnectionMeta, error) {
|
func (r *ConnectionRegistry) createConnection(req *http.Request) (*ConnectionMeta, error) {
|
||||||
ctx, cancel := context.WithCancel(r.ctx)
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
eventChan, errorChan, err := r.client.Connect(ctx, req)
|
eventChan, errorChan, err := r.client.Connect(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -180,8 +178,6 @@ func (r *ConnectionRegistry) monitorConnections() {
|
|||||||
select {
|
select {
|
||||||
case <-r.monitorStop:
|
case <-r.monitorStop:
|
||||||
return
|
return
|
||||||
case <-r.ctx.Done():
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
r.checkConnectionHealth(pingTimeout)
|
r.checkConnectionHealth(pingTimeout)
|
||||||
}
|
}
|
||||||
@@ -200,6 +196,7 @@ func (r *ConnectionRegistry) checkConnectionHealth(timeout time.Duration) {
|
|||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
if r.conn == conn { // Verify it's still the same connection
|
if r.conn == conn { // Verify it's still the same connection
|
||||||
r.conn.Cancel()
|
r.conn.Cancel()
|
||||||
|
r.monitorStop <- struct{}{}
|
||||||
r.conn = nil
|
r.conn = nil
|
||||||
}
|
}
|
||||||
r.mu.Unlock()
|
r.mu.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user