Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d8dc71f
WIP sandbox event endpoint boilerplate
0div Jun 16, 2025
d7363e9
fix merge conflict with main
0div Jun 16, 2025
587f92e
WIP working sandbox event endpoint boilerplate
0div Jun 16, 2025
61c8fe9
renaming and changes in file structure
0div Jun 17, 2025
67abc7c
fix merge conflict with main
0div Jun 19, 2025
b39dd56
WIP abstract event server in its own sandbox submodule; add some head…
0div Jun 19, 2025
4aefc4a
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jun 20, 2025
78bfc5a
cosmetic edits
0div Jun 20, 2025
599531e
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jun 20, 2025
6f1aa77
address gofumpt errors
0div Jun 20, 2025
c47a330
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jun 23, 2025
087c421
store events in redis via a catchall endpoint
0div Jun 23, 2025
19a18a7
create event store interface
0div Jun 24, 2025
d8ca2e6
fix event store
0div Jun 24, 2025
5aa2b58
go mod tidy & go work sync
0div Jun 24, 2025
59ea4ad
fix merge conflict with main
0div Jun 24, 2025
be5c2ad
go mod tidy api
0div Jun 25, 2025
eb5ca83
use sorted set for events time-series
0div Jun 25, 2025
3179789
go-lint problematic file
0div Jun 25, 2025
30e2cd8
add redis to start-services action
0div Jun 25, 2025
881fbb0
add redis_url to template-manager iac
0div Jun 25, 2025
89eb6fb
remove proto from redis url in github actions
0div Jun 25, 2025
fdc5cdb
update openapi spec for sandbox events endpoint
0div Jun 26, 2025
333bb17
fix merge conflict with main
0div Jul 2, 2025
e2e6e2c
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jul 3, 2025
6abcc04
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jul 7, 2025
fd4e9a1
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jul 8, 2025
b4bb3f6
track Sandbox IPs via store during key Sandbox lifecycle steps relati…
0div Jul 8, 2025
7535b6e
remove sandbox id middleware
0div Jul 8, 2025
d25a9f3
use public ip address for sandbox event routing that is not meant to …
0div Jul 10, 2025
60de6a2
fix merge conflict with main
0div Jul 10, 2025
4309142
golint
0div Jul 11, 2025
78ffeba
introduce internal const.go to orchestrator package
0div Jul 11, 2025
0b69432
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jul 11, 2025
6d666e6
Merge branch 'main' of https://github.com/e2b-dev/infra into create-i…
0div Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actions/start-services/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ runs:
make -C tests/integration seed
shell: bash

- name: Start Redis
run: |
docker run -d --name redis -p 6379:6379 redis:7.4.2-alpine
shell: bash

- name: Start Services
env:
ENVD_TIMEOUT: "60s"
ORCHESTRATOR_SERVICES: "orchestrator,template-manager"
SANDBOX_ACCESS_TOKEN_HASH_SEED: "abcdefghijklmnopqrstuvwxyz"
SUPABASE_JWT_SECRETS: "supabasejwtsecretsupabasejwtsecret"
TEMPLATE_MANAGER_HOST: "localhost:5008"
REDIS_URL: "localhost:6379"
ARTIFACTS_REGISTRY_PROVIDER: "Local"
STORAGE_PROVIDER: "Local"
ENVIRONMENT: "local"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/launchdarkly/go-sdk-common/v3 v3.1.0
github.com/pkg/errors v0.9.1
github.com/pressly/goose/v3 v3.24.2
github.com/redis/go-redis/v9 v9.8.0
github.com/redis/go-redis/v9 v9.10.0
github.com/stretchr/testify v1.10.0
google.golang.org/grpc v1.72.1
)
Expand Down
4 changes: 2 additions & 2 deletions packages/api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,8 @@ github.com/prometheus/procfs v0.16.0/go.mod h1:8veyXUu3nGP7oaCxhX6yeaM5u4stL2FeM
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510 h1:6ksZ7t1hNOzGPPs8DK7SvXQf6UfWzi+W5Z7PCBl8gx4=
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510/go.mod h1:UC0TwJiF90m2T3iYPQBKnGu8gv3s55dF/EgpTq8gyvo=
github.com/redis/go-redis/v9 v9.0.0-rc.4/go.mod h1:Vo3EsyWnicKnSKCA7HhgnvnyA74wOA69Cd2Meli5mmA=
github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI=
github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
Expand Down
2 changes: 1 addition & 1 deletion packages/client-proxy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/jellydator/ttlcache/v3 v3.3.1-0.20250207140243-aefc35918359
github.com/miekg/dns v1.1.63
github.com/oapi-codegen/gin-middleware v1.0.2
github.com/redis/go-redis/v9 v9.8.0
github.com/redis/go-redis/v9 v9.10.0
github.com/soheilhy/cmux v0.1.5
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0
go.opentelemetry.io/otel/metric v1.36.0
Expand Down
4 changes: 2 additions & 2 deletions packages/client-proxy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ github.com/prometheus/procfs v0.16.0 h1:xh6oHhKwnOJKMYiYBDWmkHqQPyiY40sny36Cmx2b
github.com/prometheus/procfs v0.16.0/go.mod h1:8veyXUu3nGP7oaCxhX6yeaM5u4stL2FeMXnCqhDthZg=
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510 h1:6ksZ7t1hNOzGPPs8DK7SvXQf6UfWzi+W5Z7PCBl8gx4=
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510/go.mod h1:UC0TwJiF90m2T3iYPQBKnGu8gv3s55dF/EgpTq8gyvo=
github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI=
github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/redis/rueidis v1.0.19 h1:s65oWtotzlIFN8eMPhyYwxlwLR1lUdhza2KtWprKYSo=
github.com/redis/rueidis v1.0.19/go.mod h1:8B+r5wdnjwK3lTFml5VtxjzGOQAC+5UmujoD12pDrEo=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
Expand Down
2 changes: 2 additions & 0 deletions packages/nomad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ locals {
otel_collector_grpc_endpoint = "localhost:${var.otel_collector_grpc_port}"
allow_sandbox_internet = var.allow_sandbox_internet
launch_darkly_api_key = trimspace(data.google_secret_manager_secret_version.launch_darkly_api_key.secret_data)
redis_url = data.google_secret_manager_secret_version.redis_url.secret_data != "redis.service.consul" ? "${data.google_secret_manager_secret_version.redis_url.secret_data}:${var.redis_port.port}" : "redis.service.consul:${var.redis_port.port}"
}

orchestrator_job_check = templatefile("${path.module}/orchestrator.hcl", merge(
Expand Down Expand Up @@ -485,6 +486,7 @@ resource "nomad_job" "template_manager" {
logs_collector_public_ip = var.logs_proxy_address
orchestrator_services = "template-manager"
allow_sandbox_internet = var.allow_sandbox_internet
redis_url = data.google_secret_manager_secret_version.redis_url.secret_data != "redis.service.consul" ? "${data.google_secret_manager_secret_version.redis_url.secret_data}:${var.redis_port.port}" : "redis.service.consul:${var.redis_port.port}"
})
}
resource "nomad_job" "loki" {
Expand Down
1 change: 1 addition & 0 deletions packages/nomad/orchestrator.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ EOT
TEMPLATE_BUCKET_NAME = "${template_bucket_name}"
OTEL_COLLECTOR_GRPC_ENDPOINT = "${otel_collector_grpc_endpoint}"
ALLOW_SANDBOX_INTERNET = "${allow_sandbox_internet}"
REDIS_URL = "${redis_url}"

%{ if launch_darkly_api_key != "" }
LAUNCH_DARKLY_API_KEY = "${launch_darkly_api_key}"
Expand Down
1 change: 1 addition & 0 deletions packages/nomad/template-manager.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ job "template-manager" {
ORCHESTRATOR_SERVICES = "${orchestrator_services}"
LOGS_COLLECTOR_PUBLIC_IP = "${logs_collector_public_ip}"
ALLOW_SANDBOX_INTERNET = "${allow_sandbox_internet}"
REDIS_URL = "${redis_url}"
%{ if !update_stanza }
FORCE_STOP = "true"
%{ endif }
Expand Down
4 changes: 3 additions & 1 deletion packages/orchestrator/cmd/build-template/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ import (
"github.com/e2b-dev/infra/packages/shared/pkg/storage"
)

const proxyPort = 5007
const (
proxyPort = 5007
)

func main() {
ctx, cancel := context.WithCancel(context.Background())
Expand Down
2 changes: 2 additions & 0 deletions packages/orchestrator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/ngrok/firewall_toolkit v0.0.18
github.com/pkg/errors v0.9.1
github.com/pojntfx/go-nbd v0.3.2
github.com/redis/go-redis/v9 v9.10.0
github.com/rs/zerolog v1.34.0
github.com/soheilhy/cmux v0.1.5
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -94,6 +95,7 @@ require (
github.com/containernetworking/cni v1.2.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dchest/uniuri v1.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v28.2.2+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
Expand Down
8 changes: 8 additions & 0 deletions packages/orchestrator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnweb
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
Expand Down Expand Up @@ -339,6 +343,8 @@ github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0=
github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
Expand Down Expand Up @@ -941,6 +947,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
13 changes: 13 additions & 0 deletions packages/orchestrator/internal/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package internal

import (
"github.com/e2b-dev/infra/packages/shared/pkg/env"
)

const (
defaultSandboxEventIP = "203.0.113.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you use TEST-NET-3 here?

)

func GetSandboxEventIP() string {
return env.GetEnv("SANDBOX_EVENT_IP", defaultSandboxEventIP)
}
123 changes: 123 additions & 0 deletions packages/orchestrator/internal/sandbox/event/handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package event

import (
"context"
"encoding/json"
"io"
"net/http"
"strings"

"go.uber.org/zap"
)

type EventHandler interface {
Path() string
HandlerFunc(w http.ResponseWriter, r *http.Request)
}

type MetricsHandler struct{}

func (h *MetricsHandler) Path() string {
return "/metrics"
}

func (h *MetricsHandler) HandlerFunc(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
_, err := w.Write([]byte(`{"event_ack":true,"path":"/metrics"}`))
if err != nil {
http.Error(w, "Failed to write response", http.StatusInternalServerError)
return
}
}

// This is used to track ad-hoc events that are not handled by the event server.
type DefaultHandler struct {
store SandboxEventStore
}

func (h *DefaultHandler) Path() string {
return "/"
}

func (h *DefaultHandler) HandlerFunc(w http.ResponseWriter, r *http.Request) {
addr := r.RemoteAddr
ip := strings.Split(addr, ":")[0]
sandboxID, err := h.store.GetSandboxIP(ip)
if err != nil {
zap.L().Error("Failed to get sandbox ID from IP", zap.Error(err))
http.Error(w, "Error handling event", http.StatusInternalServerError)
return
}

zap.L().Debug("Received request from sandbox", zap.String("sandbox_id", sandboxID), zap.String("ip", ip))

if r.Method == http.MethodGet {
events, err := h.store.GetLastNEvents(sandboxID, 10)
if err != nil {
zap.L().Error("Failed to get event data for sandbox "+sandboxID, zap.Error(err))
http.Error(w, "Failed to get event data for sandbox "+sandboxID, http.StatusInternalServerError)
return
}

eventJSON, err := json.Marshal(events)
if err != nil {
zap.L().Error("Failed to marshal event data", zap.Error(err))
http.Error(w, "Failed to marshal event data", http.StatusInternalServerError)
return
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(eventJSON)
return
}

if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}

// Create event data with path and body
eventData := SandboxEvent{
Path: r.URL.Path,
}

body, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, "Failed to read request body", http.StatusInternalServerError)
return
}

zap.L().Info("Received event", zap.String("body", string(body)))

eventData.Body = make(map[string]any)
err = json.Unmarshal(body, &eventData.Body)
if err != nil {
zap.L().Error("Failed to unmarshal request body", zap.Error(err))
http.Error(w, "Failed to unmarshal request body", http.StatusInternalServerError)
return
}

// Store in Redis with sandboxID as key
err = h.store.AddEvent(sandboxID, &eventData, 0)
if err != nil {
zap.L().Error("Failed to store event data", zap.Error(err))
http.Error(w, "Failed to store event data", http.StatusInternalServerError)
return
}

w.WriteHeader(http.StatusCreated)
w.Write([]byte(`{"event_ack":true}`))
}

func NewEventHandlers(ctx context.Context, store SandboxEventStore) []EventHandler {
return []EventHandler{
&MetricsHandler{},
&DefaultHandler{store},
}
}
48 changes: 48 additions & 0 deletions packages/orchestrator/internal/sandbox/event/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package event

import (
"context"
"fmt"
"net/http"
)

// SandboxEventServer handles outbound HTTP requests from sandboxes calling the event.e2b.com endpoint
type SandboxEventServer struct {
server *http.Server
}

func NewSandboxEventServer(port uint, handlers []EventHandler) *SandboxEventServer {
mux := http.NewServeMux()

for _, handler := range handlers {
mux.HandleFunc(handler.Path(), handler.HandlerFunc)
}

server := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: mux,
}
Comment on lines +21 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about running Gin here so we can use a strict Golang client in envd and track all version changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, we can use gin, but i'm not sure it's more strict than the std lib and also what do u mean by tracking version changes in this case?

Copy link
Member

@sitole sitole Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but i'm not sure it's more strict than the std lib and also what do u mean by tracking version changes in this case?

I was thinking that the "metrics server" can be Gin-backed by the OpenAPI scheme, as we are using for the API, so all breaking changes will be clear (because of the re-generated schema). You will also be able to use the generated Go client from EnvD to call metrics service endpoints.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point was just make it strong types on both caller and receiver

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @sitole


return &SandboxEventServer{
server: server,
}
}

func (p *SandboxEventServer) Start() error {
return p.server.ListenAndServe()
}

func (p *SandboxEventServer) Close(ctx context.Context) error {
var err error
select {
case <-ctx.Done():
err = p.server.Close()
default:
err = p.server.Shutdown(ctx)
}
if err != nil {
return fmt.Errorf("failed to shutdown event server: %w", err)
}

return nil
}
Loading
Loading