Skip to content

Commit 9f595bd

Browse files
authored
[#251]: http: switch worker delivery from pool.Exec to ConnectRPC
2 parents 60ab5b2 + 25ecd58 commit 9f595bd

40 files changed

Lines changed: 2799 additions & 3541 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.dll
55
*.so
66
*.dylib
7+
.claude/settings.local.json
78

89
# Test binary, built with `go test -c`
910
*.test

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ linters:
3232
- unused
3333
- whitespace
3434
settings:
35-
dupl:
36-
threshold: 100
3735
gocyclo:
3836
min-complexity: 20
3937
godot:

config/config.go

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"strings"
5+
"time"
56

67
"github.com/roadrunner-server/http/v6/servers/fcgi"
78
"github.com/roadrunner-server/http/v6/servers/http3"
@@ -13,16 +14,16 @@ import (
1314

1415
// Config configures RoadRunner HTTP server.
1516
type Config struct {
16-
// RawBody if turned on, RR will not parse the incoming HTTP body and will send it as is
17-
RawBody bool `mapstructure:"raw_body"`
1817
// Host and port to handle as http server.
1918
Address string `mapstructure:"address"`
2019
// AccessLogs turn on/off, logged at Info log level, default: false
2120
AccessLogs bool `mapstructure:"access_logs"`
2221
// List of the middleware names (order will be preserved)
2322
Middleware []string `mapstructure:"middleware"`
24-
// Pool configures worker pool.
23+
// Pool configures worker pool (lifecycle only; requests are delivered via Proxy).
2524
Pool *pool.Config `mapstructure:"pool"`
25+
// Proxy configures the worker-facing ConnectRPC server.
26+
Proxy *Proxy `mapstructure:"proxy"`
2627
// InternalErrorCode used to override default 500 (InternalServerError) http code
2728
InternalErrorCode uint64 `mapstructure:"internal_error_code"`
2829
// MaxRequestSize specified max size for payload body in megabytes. 0 = 1GB.
@@ -42,6 +43,33 @@ type Config struct {
4243
GID int
4344
}
4445

46+
// Proxy configures the ConnectRPC server that PHP workers connect into.
47+
type Proxy struct {
48+
// Address is the TCP address the proxy server listens on, e.g. ":7070".
49+
Address string `mapstructure:"address"`
50+
// RequestTimeout caps how long a single request can sit waiting for a
51+
// worker to produce a response. Defaults to 60s.
52+
RequestTimeout time.Duration `mapstructure:"request_timeout"`
53+
// InboxSize bounds the in-process request queue. Submits beyond this
54+
// return 503 to the client. Defaults to 1024.
55+
InboxSize int `mapstructure:"inbox_size"`
56+
// DebugMode flips the handler into debug mode (verbose error bodies on 5xx).
57+
DebugMode bool `mapstructure:"debug"`
58+
}
59+
60+
func (p *Proxy) InitDefaults() {
61+
if p.Address == "" {
62+
// Bind to loopback by default
63+
p.Address = "127.0.0.1:7070"
64+
}
65+
if p.RequestTimeout == 0 {
66+
p.RequestTimeout = time.Minute
67+
}
68+
if p.InboxSize == 0 {
69+
p.InboxSize = 1024
70+
}
71+
}
72+
4573
// EnableHTTP is true when http server must run.
4674
func (c *Config) EnableHTTP() bool {
4775
return c.Address != ""
@@ -78,6 +106,11 @@ func (c *Config) InitDefaults() error {
78106
}
79107
c.Pool.InitDefaults()
80108

109+
if c.Proxy == nil {
110+
c.Proxy = &Proxy{}
111+
}
112+
c.Proxy.InitDefaults()
113+
81114
if c.InternalErrorCode == 0 {
82115
c.InternalErrorCode = 500
83116
}
@@ -124,6 +157,15 @@ func (c *Config) Valid() error {
124157
return errors.E(op, "malformed pool config")
125158
}
126159

160+
if c.Proxy != nil {
161+
if c.Proxy.RequestTimeout < 0 {
162+
return errors.E(op, errors.Str("proxy.request_timeout must be >= 0"))
163+
}
164+
if c.Proxy.InboxSize < 0 {
165+
return errors.E(op, errors.Str("proxy.inbox_size must be >= 0"))
166+
}
167+
}
168+
127169
if !c.EnableHTTP() && !c.EnableTLS() && !c.EnableFCGI() {
128170
return errors.E(op, errors.Str("unable to run http service, no method has been specified (http, https, http/2 or FastCGI)"))
129171
}

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ require (
99
github.com/google/uuid v1.6.0
1010
github.com/mholt/acmez v1.2.0
1111
github.com/prometheus/client_golang v1.23.2
12-
github.com/quic-go/quic-go v0.59.0
13-
github.com/roadrunner-server/api-go/v6 v6.0.0-beta.5
12+
github.com/quic-go/quic-go v0.59.1
13+
github.com/roadrunner-server/api-go/v6 v6.0.0-beta.12
1414
github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2
1515
github.com/roadrunner-server/context v1.3.0
1616
github.com/roadrunner-server/endure/v2 v2.6.2
1717
github.com/roadrunner-server/errors v1.5.0
18-
github.com/roadrunner-server/goridge/v4 v4.0.0-beta.1
1918
github.com/roadrunner-server/pool/v2 v2.0.0-beta.1
2019
github.com/roadrunner-server/tcplisten v1.5.2
2120
github.com/stretchr/testify v1.11.1
@@ -25,7 +24,7 @@ require (
2524
go.opentelemetry.io/otel/trace v1.43.0
2625
golang.org/x/net v0.54.0
2726
golang.org/x/sys v0.44.0
28-
google.golang.org/genproto v0.0.0-20260504160031-60b97b32f348
27+
google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60
2928
google.golang.org/protobuf v1.36.11
3029
)
3130

@@ -49,9 +48,10 @@ require (
4948
github.com/prometheus/procfs v0.20.1 // indirect
5049
github.com/quic-go/qpack v0.6.0 // indirect
5150
github.com/roadrunner-server/events v1.0.1 // indirect
51+
github.com/roadrunner-server/goridge/v4 v4.0.0-beta.2 // indirect
5252
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
53-
github.com/tklauser/go-sysconf v0.3.16 // indirect
54-
github.com/tklauser/numcpus v0.11.0 // indirect
53+
github.com/tklauser/go-sysconf v0.4.0 // indirect
54+
github.com/tklauser/numcpus v0.12.0 // indirect
5555
github.com/yusufpapurcu/wmi v1.2.4 // indirect
5656
github.com/zeebo/blake3 v0.2.4 // indirect
5757
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
@@ -66,7 +66,7 @@ require (
6666
golang.org/x/sync v0.20.0 // indirect
6767
golang.org/x/text v0.37.0 // indirect
6868
golang.org/x/tools v0.45.0 // indirect
69-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 // indirect
70-
google.golang.org/grpc v1.81.0 // indirect
69+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260511170946-3700d4141b60 // indirect
70+
google.golang.org/grpc v1.81.1 // indirect
7171
gopkg.in/yaml.v3 v3.0.1 // indirect
7272
)

go.sum

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEy
6262
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
6363
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
6464
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
65-
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
66-
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
67-
github.com/roadrunner-server/api-go/v6 v6.0.0-beta.5 h1:4x17K8qmxIbtKrCKoY1NR7bBvJbrB7w0P/0ovYR8C6E=
68-
github.com/roadrunner-server/api-go/v6 v6.0.0-beta.5/go.mod h1:B9CjHMnKrAUNM99XckiA8NEKg0oid22KqejR+lRnohw=
65+
github.com/quic-go/quic-go v0.59.1 h1:0Gmua0HW1Tv7ANR7hUYwRyD0MG5OJfgvYSZasGZzBic=
66+
github.com/quic-go/quic-go v0.59.1/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
67+
github.com/roadrunner-server/api-go/v6 v6.0.0-beta.12 h1:FcRcCvW9OfQvH45SFsI21VoHpOOov56OvOSnO4UKvXs=
68+
github.com/roadrunner-server/api-go/v6 v6.0.0-beta.12/go.mod h1:prGWJ2GoF5YD5PIG7Tb6VKulU3bWoFwr9DCwgxheb80=
6969
github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2 h1:GqsZzWQ5jMXRF1O/b8IqFz9PLpS7Ui0K4OyACLql2MI=
7070
github.com/roadrunner-server/api-plugins/v6 v6.0.0-beta.2/go.mod h1:2v4yUK5Kvbvq8C3IkDoBkuamq9h+7i/JLjyf7k1j5JM=
7171
github.com/roadrunner-server/context v1.3.0 h1:iyTXVORhPU2/26z7kdzEaggwG5P8yhIKUDLiePjylFQ=
@@ -76,8 +76,8 @@ github.com/roadrunner-server/errors v1.5.0 h1:unG7LKIZrSzkCCF3YLRLA5VyqE0KKomofX
7676
github.com/roadrunner-server/errors v1.5.0/go.mod h1:g9fo/T2C13cWRDR9PW1r0ZAOSQfNhWAZawyfkGiaHuI=
7777
github.com/roadrunner-server/events v1.0.1 h1:waCkKhxhzdK3VcI1xG22l+h+0J+Nfdpxjhyy01Un+kI=
7878
github.com/roadrunner-server/events v1.0.1/go.mod h1:WZRqoEVaFm209t52EuoT7ISUtvX6BrCi6bI/7pjkVC0=
79-
github.com/roadrunner-server/goridge/v4 v4.0.0-beta.1 h1:dO1wKnuMr4xMmH6DY2ZaZ6FWS+Vo50+C7fuAcyO/xBk=
80-
github.com/roadrunner-server/goridge/v4 v4.0.0-beta.1/go.mod h1:+gKla9HAyYlk0TsC9VktwtOL63aimsWT3oPsuCLh4/o=
79+
github.com/roadrunner-server/goridge/v4 v4.0.0-beta.2 h1:MgH6oiSgcl+vphsQ6JpyedkXQ/DPf8zVpn0z7rdBp10=
80+
github.com/roadrunner-server/goridge/v4 v4.0.0-beta.2/go.mod h1:Wv9CBO9VIU92e5iZIuehLHKakXgMkOzxoT4/oHDjIUA=
8181
github.com/roadrunner-server/pool/v2 v2.0.0-beta.1 h1:jpYXFtdD6QGAdAGPgMxrNi3j1CegCRpb2y+A+3GnXFA=
8282
github.com/roadrunner-server/pool/v2 v2.0.0-beta.1/go.mod h1:Bo1wT7RtL3eyQHXBUohNhtj/yAmRt6Rq8smuBg5pWkY=
8383
github.com/roadrunner-server/tcplisten v1.5.2 h1:nn8yXYrhRDkfQ9AAu4V075uT4fZRmOnpxkawgE+bWPA=
@@ -88,10 +88,10 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl
8888
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
8989
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
9090
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
91-
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
92-
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
93-
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
94-
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
91+
github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU=
92+
github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=
93+
github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=
94+
github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
9595
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
9696
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
9797
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
@@ -148,12 +148,12 @@ golang.org/x/tools v0.45.0 h1:18qN3FAooORvApf5XjCXgsuayZOEtXf6JK18I3+ONa8=
148148
golang.org/x/tools v0.45.0/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0=
149149
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
150150
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
151-
google.golang.org/genproto v0.0.0-20260504160031-60b97b32f348 h1:JjVGDZYWkJWZcxveJGzfkXC5myDVWAd4dZdgbzrDUv8=
152-
google.golang.org/genproto v0.0.0-20260504160031-60b97b32f348/go.mod h1:95PqD4xM+AdOcBGsmgfaofXsiA37uXDtDufVbntT3TU=
153-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 h1:pfIbyB44sWzHiCpRqIen67ZQnVXSfIxWrqUMk1qwODE=
154-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
155-
google.golang.org/grpc v1.81.0 h1:W3G9N3KQf3BU+YuCtGKJk0CmxQNbAISICD/9AORxLIw=
156-
google.golang.org/grpc v1.81.0/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
151+
google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60 h1:rhBdfmsOlOZIvz3Y5/BdUzPg2CkO8L7QQPKj96B8554=
152+
google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60/go.mod h1:8xo2Pj1b20ZOCpzlU3B9qieMwVIAXx1QVZWLMlPL6sM=
153+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260511170946-3700d4141b60 h1:seT2EwLWM78plQ7wcDfuWBc/4FAEAXDDiaSol4ku4qo=
154+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260511170946-3700d4141b60/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
155+
google.golang.org/grpc v1.81.1 h1:VnnIIZ88UzOOKLukQi+ImGz8O1Wdp8nAGGnvOfEIWQQ=
156+
google.golang.org/grpc v1.81.1/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
157157
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
158158
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
159159
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)