Skip to content

Commit 686c231

Browse files
maksymlumenclaude
andcommitted
feat: pre-warm gRPC connections on module registration
When a module address is registered, immediately dial the connection in the background. This eliminates cold start latency on the first request to that module. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f59d490 commit 686c231

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

internal/client/pool.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ func (p *AddressPool) Register(moduleName, addr string) {
3636
"addr", addr,
3737
)
3838
p.addressTable.Set(moduleName, addr)
39+
40+
// Pre-warm connection in background to avoid cold start latency on first request
41+
if p.runCtx != nil {
42+
go func() {
43+
if _, err := p.getClient(p.runCtx, addr); err != nil {
44+
p.log.Error(err, "address pool: failed to pre-warm connection",
45+
"module", moduleName,
46+
"addr", addr,
47+
)
48+
} else {
49+
p.log.Info("address pool: connection pre-warmed",
50+
"module", moduleName,
51+
"addr", addr,
52+
)
53+
}
54+
}()
55+
}
3956
}
4057

4158
func (p *AddressPool) Deregister(moduleName string) {

0 commit comments

Comments
 (0)