Skip to content

Commit 90e639d

Browse files
committed
orchestrator: renamed session proxy to sandbox proxy
1 parent 10f5833 commit 90e639d

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

packages/orchestrator/cmd/mock-sandbox/mock.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func mockSandbox(
108108
buildId,
109109
sandboxId string,
110110
dns *dns.DNS,
111-
proxy *proxy.SessionProxy,
111+
proxy *proxy.SandboxProxy,
112112
keepAlive time.Duration,
113113
networkPool *network.Pool,
114114
templateCache *template.Cache,

packages/orchestrator/cmd/mock-snapshot/mock.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func mockSnapshot(
116116
buildId,
117117
sandboxId string,
118118
dns *dns.DNS,
119-
proxy *proxy.SessionProxy,
119+
proxy *proxy.SandboxProxy,
120120
keepAlive time.Duration,
121121
networkPool *network.Pool,
122122
templateCache *template.Cache,

packages/orchestrator/internal/proxy/proxy.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ var browserIdentityKeywords = []string{
2323
"mozilla", "chrome", "safari", "firefox", "edge", "opera", "msie",
2424
}
2525

26-
type SessionProxy struct {
26+
type SandboxProxy struct {
2727
sandboxes *smap.Map[string]
2828
server *http.Server
2929
}
3030

31-
func New(port uint) *SessionProxy {
31+
func New(port uint) *SandboxProxy {
3232
server := &http.Server{Addr: fmt.Sprintf(":%d", port)}
3333

34-
return &SessionProxy{
34+
return &SandboxProxy{
3535
server: server,
3636
sandboxes: smap.New[string](),
3737
}
3838
}
3939

40-
func (p *SessionProxy) AddSandbox(sandboxID, ip string) {
40+
func (p *SandboxProxy) AddSandbox(sandboxID, ip string) {
4141
p.sandboxes.Insert(sandboxID, ip)
4242
}
4343

44-
func (p *SessionProxy) RemoveSandbox(sandboxID string) {
44+
func (p *SandboxProxy) RemoveSandbox(sandboxID string) {
4545
p.sandboxes.Remove(sandboxID)
4646
}
4747

48-
func (p *SessionProxy) Start() error {
48+
func (p *SandboxProxy) Start() error {
4949
// similar values to our old the nginx configuration
5050
serverTransport := &http.Transport{
5151
Proxy: http.ProxyFromEnvironment,
@@ -61,14 +61,14 @@ func (p *SessionProxy) Start() error {
6161
return p.server.ListenAndServe()
6262
}
6363

64-
func (p *SessionProxy) Shutdown(ctx context.Context) {
64+
func (p *SandboxProxy) Shutdown(ctx context.Context) {
6565
err := p.server.Shutdown(ctx)
6666
if err != nil {
6767
zap.L().Error("failed to shutdown proxy server", zap.Error(err))
6868
}
6969
}
7070

71-
func (p *SessionProxy) proxyHandler(transport *http.Transport) func(w http.ResponseWriter, r *http.Request) {
71+
func (p *SandboxProxy) proxyHandler(transport *http.Transport) func(w http.ResponseWriter, r *http.Request) {
7272
activeConnections, err := meters.GetUpDownCounter(meters.ActiveConnectionsCounterMeterName)
7373
if err != nil {
7474
zap.L().Error("failed to create active connections counter", zap.Error(err))
@@ -146,7 +146,7 @@ func (p *SessionProxy) proxyHandler(transport *http.Transport) func(w http.Respo
146146
}
147147
}
148148

149-
func (p *SessionProxy) buildHtmlClosedPortError(sandboxId string, host string, port uint64) []byte {
149+
func (p *SandboxProxy) buildHtmlClosedPortError(sandboxId string, host string, port uint64) []byte {
150150
replacements := map[string]string{
151151
"{{sandbox_id}}": sandboxId,
152152
"{{sandbox_port}}": strconv.FormatUint(port, 10),
@@ -161,7 +161,7 @@ func (p *SessionProxy) buildHtmlClosedPortError(sandboxId string, host string, p
161161
return []byte(adjustedErrTemplate)
162162
}
163163

164-
func (p *SessionProxy) buildJsonClosedPortError(sandboxId string, port uint64) []byte {
164+
func (p *SandboxProxy) buildJsonClosedPortError(sandboxId string, port uint64) []byte {
165165
response := map[string]interface{}{
166166
"error": "The sandbox is running but port is not open",
167167
"sandbox_id": sandboxId,
@@ -172,7 +172,7 @@ func (p *SessionProxy) buildJsonClosedPortError(sandboxId string, port uint64) [
172172
return responseBytes
173173
}
174174

175-
func (p *SessionProxy) isBrowser(userAgent string) bool {
175+
func (p *SandboxProxy) isBrowser(userAgent string) bool {
176176
userAgent = strings.ToLower(userAgent)
177177
for _, keyword := range browserIdentityKeywords {
178178
if strings.Contains(userAgent, keyword) {

packages/orchestrator/internal/sandbox/sandbox_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func NewSandbox(
8787
ctx context.Context,
8888
tracer trace.Tracer,
8989
dns *dns.DNS,
90-
proxy *proxy.SessionProxy,
90+
proxy *proxy.SandboxProxy,
9191
networkPool *network.Pool,
9292
templateCache *template.Cache,
9393
config *orchestrator.SandboxConfig,

packages/orchestrator/internal/sandbox/sandbox_other.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ func (s *Sandbox) LoggerMetadata() sbxlogger.SandboxMetadata {
6969
// Run cleanup functions for the already initialized resources if there is any error or after you are done with the started sandbox.
7070
func NewSandbox(
7171

72-
// YOU ARE IN SANDBOX_OTHER.GO
73-
// YOU PROBABLY WANT TO BE IN SANDBOX_LINUX.GO
72+
// YOU ARE IN SANDBOX_OTHER.GO
73+
// YOU PROBABLY WANT TO BE IN SANDBOX_LINUX.GO
7474

7575
ctx context.Context,
7676
tracer trace.Tracer,
7777
dns *dns.DNS,
78-
proxy *proxy.SessionProxy,
78+
proxy *proxy.SandboxProxy,
7979
networkPool *network.Pool,
8080
templateCache *template.Cache,
8181
config *orchestrator.SandboxConfig,

packages/orchestrator/internal/server/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type server struct {
3939
orchestrator.UnimplementedSandboxServiceServer
4040
sandboxes *smap.Map[*sandbox.Sandbox]
4141
dns *dns.DNS
42-
proxy *proxy.SessionProxy
42+
proxy *proxy.SandboxProxy
4343
tracer trace.Tracer
4444
networkPool *network.Pool
4545
templateCache *template.Cache
@@ -56,7 +56,7 @@ type Service struct {
5656
server *server
5757
grpc *grpc.Server
5858
dns *dns.DNS
59-
proxy *proxy.SessionProxy
59+
proxy *proxy.SandboxProxy
6060
port uint16
6161
shutdown struct {
6262
once sync.Once
@@ -71,7 +71,7 @@ type Service struct {
7171
useClickhouseMetrics string
7272
}
7373

74-
func New(ctx context.Context, port uint, clientID string, proxy *proxy.SessionProxy) (*Service, error) {
74+
func New(ctx context.Context, port uint, clientID string, proxy *proxy.SandboxProxy) (*Service, error) {
7575
if port > math.MaxUint16 {
7676
return nil, fmt.Errorf("%d is larger than maximum possible port %d", port, math.MaxInt16)
7777
}

0 commit comments

Comments
 (0)