Skip to content

Commit fe8fdaf

Browse files
authored
Merge pull request #37 from FireTail-io/buffer-channels
Buffer channels
2 parents 0d6b19d + 41c1561 commit fe8fdaf

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

main.go

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func main() {
2525
log.Println("Firetail extension starting in debug mode.")
2626
}
2727

28+
// Log the value of AWS_LAMBDA_EXEC_WRAPPER and AWS_LAMBDA_RUNTIME_API for debugging
29+
log.Println("AWS_LAMBDA_EXEC_WRAPPER:", os.Getenv("AWS_LAMBDA_EXEC_WRAPPER"))
30+
log.Println("AWS_LAMBDA_RUNTIME_API:", os.Getenv("AWS_LAMBDA_RUNTIME_API"))
31+
2832
// This context will be cancelled whenever a SIGTERM or SIGINT signal is received
2933
// We'll use it for our requests to the extensions API & to shutdown the log server
3034
ctx := getContext()

proxy/proxy.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ func NewProxyServer() (*ProxyServer, error) {
3636
ps := &ProxyServer{
3737
runtimeEndpoint: os.Getenv("AWS_LAMBDA_RUNTIME_API"),
3838
port: port,
39-
eventsChannel: make(chan *http.Response),
40-
lambdaResponseChannel: make(chan *http.Request),
41-
RecordsChannel: make(chan firetail.Record),
39+
eventsChannel: make(chan *http.Response, 1),
40+
lambdaResponseChannel: make(chan *http.Request, 1),
41+
RecordsChannel: make(chan firetail.Record, 100),
4242
}
4343

4444
r := chi.NewRouter()

proxy/proxy_handler.go

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package proxy
22

33
import (
44
"io"
5+
"log"
56
"net/http"
67
"net/url"
78
"strings"
@@ -34,6 +35,7 @@ func getProxyHandler(urlMappingFunc func(r *http.Request) (*url.URL, error), req
3435

3536
// Send the request to the requestChannel with the copied body if the channel was provided
3637
if requestChannel != nil {
38+
log.Println("Captured lambda response", requestBodyCopy.String())
3739
r.Body = io.NopCloser(strings.NewReader(requestBodyCopy.String()))
3840
*requestChannel <- r
3941
}
@@ -57,6 +59,7 @@ func getProxyHandler(urlMappingFunc func(r *http.Request) (*url.URL, error), req
5759

5860
// Send the response to the responseChannel with the copied body if the channel was provided
5961
if responseChannel != nil {
62+
log.Println("Captured event", responseBodyCopy.String())
6063
resp.Body = io.NopCloser(strings.NewReader(responseBodyCopy.String()))
6164
*responseChannel <- resp
6265
}

0 commit comments

Comments
 (0)