MCPcopy Create free account
hub / github.com/PostHog/duckgres / NewFlightExecutor

Function NewFlightExecutor

server/flightclient/flight_executor.go:74–105  ·  view source on GitHub ↗

NewFlightExecutor creates a FlightExecutor connected to the given address. addr should be "unix:///path/to/socket" for Unix sockets or "host:port" for TCP. bearerToken is the authentication token for the duckdb-service. sessionToken is the session identifier for the x-duckgres-session header.

(addr, bearerToken, sessionToken string)

Source from the content-addressed store, hash-verified

72
73func (l *QueryLogLimiter) tryAcquire() bool {
74 for {
75 current := l.inFlight.Load()
76 if current >= l.limit {
77 return false
78 }
79 if l.inFlight.CompareAndSwap(current, current+1) {
80 return true
81 }
82 }
83}
84
85func (l *QueryLogLimiter) release() {
86 l.inFlight.Add(-1)
87}
88
89// FlightExecutor implements QueryExecutor backed by an Arrow Flight SQL client.
90// It routes queries to a duckdb-service worker process over a Unix socket.
91type FlightExecutor struct {
92 client *flightsql.Client
93 sessionToken string
94 workerID int
95 cpInstanceID string
96 ownerEpoch int64
97 alloc memory.Allocator
98 ownsClient bool // if true, Close() closes the client
99
100 // dead is set to true when the backing worker crashes. Once set, all
101 // RPC methods return ErrWorkerDead without touching the gRPC client.
102 dead atomic.Bool
103
104 ctx context.Context // base context for all requests
105 cancel context.CancelFunc // cancels the base context
106
107 // lastProfiling stores the most recent DuckDB profiling output received
108 // from the worker via gRPC trailing metadata.

Callers

nothing calls this directly

Calls 1

OTELGRPCClientHandlerFunction · 0.92

Tested by

no test coverage detected