Skip to content

Commit

Permalink
optionally supply env in start request
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoScheufler committed Dec 18, 2024
1 parent bb935eb commit f6a35b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion connect/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Connect(ctx context.Context, opts Opts, invoker FunctionInvoker, logger *sl
notifyConnectDoneChan: make(chan connectReport),
notifyConnectedChan: make(chan struct{}),
initiateConnectionChan: make(chan struct{}),
apiClient: newWorkerApiClient(opts.APIBaseUrl),
apiClient: newWorkerApiClient(opts.APIBaseUrl, opts.Env),
}

wp := NewWorkerPool(ctx, opts.WorkerConcurrency, ch.processExecutorRequest)
Expand Down
8 changes: 7 additions & 1 deletion connect/workerapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import (

type workerApiClient struct {
client http.Client
env *string
apiBaseUrl string
}

func newWorkerApiClient(apiBaseUrl string) *workerApiClient {
func newWorkerApiClient(apiBaseUrl string, env *string) *workerApiClient {
return &workerApiClient{
apiBaseUrl: apiBaseUrl,
env: env,
}
}

Expand All @@ -35,6 +37,10 @@ func (a *workerApiClient) start(ctx context.Context, hashedSigningKey []byte, re
httpReq.Header.Set("Content-Type", "application/protobuf")
httpReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", string(hashedSigningKey)))

if a.env != nil {
httpReq.Header.Add("X-Inngest-Env", *a.env)
}

httpRes, err := a.client.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("could not send start request: %w", err)
Expand Down

0 comments on commit f6a35b6

Please sign in to comment.