Skip to content

Commit

Permalink
trying buffered channel instead of parallel requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh Shukla committed Dec 29, 2024
1 parent 1b81e73 commit 94f30c9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/server/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func newSessionContext(agentID string, sessionID string, hostname string, versio
}
session := &AgentContext{
AgentKey: key,
requestChan: make(chan serviceRequest),
requestChan: make(chan serviceRequest, 100),
LastUse: now,
ConnectedAt: now,
Hostname: hostname,
Expand Down
44 changes: 22 additions & 22 deletions internal/serviceconfig/service_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ func addDefaults(ctx context.Context, server *http.Server) {

func fixedIdentityAPIHandlerMaker(em EchoManager, routes Destinations, service IncomingServiceConfig) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
go func() {
ep := SearchSpec{
Destination: service.Destination,
ServiceType: service.ServiceType,
ServiceName: service.DestinationService,
}
go runAPIHandler(em, routes, ep, w, r)
}()
// go func() {
ep := SearchSpec{
Destination: service.Destination,
ServiceType: service.ServiceType,
ServiceName: service.DestinationService,
}
runAPIHandler(em, routes, ep, w, r)
// }()
}
}

Expand Down Expand Up @@ -165,20 +165,20 @@ func extractEndpoint(r *http.Request) (agentIdentity string, endpointType string

func secureAPIHandlerMaker(em EchoManager, routes Destinations, service IncomingServiceConfig) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
go func() {
agentIdentity, endpointType, endpointName, err := extractEndpoint(r)
if err != nil {
r.Body.Close()
w.WriteHeader(http.StatusBadRequest)
return
}
ep := SearchSpec{
Destination: agentIdentity,
ServiceType: endpointType,
ServiceName: endpointName,
}
runAPIHandler(em, routes, ep, w, r)
}()
// go func() {
agentIdentity, endpointType, endpointName, err := extractEndpoint(r)
if err != nil {
r.Body.Close()
w.WriteHeader(http.StatusBadRequest)
return
}
ep := SearchSpec{
Destination: agentIdentity,
ServiceType: endpointType,
ServiceName: endpointName,
}
runAPIHandler(em, routes, ep, w, r)
// }()
}
}

Expand Down

0 comments on commit 94f30c9

Please sign in to comment.