feat(surf): AssembleRouter builds the router and handler once; the router stops the MCP endpoint it mounted (quick-261118-lbt)
- surf.AssembleRouter returns the router and the compiled handler from one build, so an mcp.enabled app is not built twice; Assemble keeps its signature and is implemented on top of it - serve uses AssembleRouter with a deferred Router.Close - pier.Pier.Close stops the session reaper and the Redis warm-up; the router that mounted the endpoint owns it - ExampleAssembleRouter, routing/testing docs and the surf/pier READMEs
This commit is contained in:
@@ -61,12 +61,25 @@ type Pier struct {
|
||||
instance string
|
||||
|
||||
// stopReap ends the session reaper (and a Redis store's warm-up) Mount
|
||||
// starts. backpack.App has no shutdown hook yet, so in production the
|
||||
// reaper runs for the life of the process, like the store subscription;
|
||||
// when backpack gains one, Mount registers stopReap there.
|
||||
// starts; Close calls it. The surf router that mounted the endpoint
|
||||
// calls Close when it is closed. backpack.App still has no shutdown
|
||||
// hook, so without a router Close the reaper runs for the life of the
|
||||
// process, like the store subscription.
|
||||
stopReap context.CancelFunc
|
||||
}
|
||||
|
||||
// Close stops the session reaper and the Redis store warm-up Mount started.
|
||||
// It does not end connected sessions; serve's HTTP drain handles those.
|
||||
// Close is safe on a nil Pier and when called more than once; it always
|
||||
// returns nil.
|
||||
func (p *Pier) Close() error {
|
||||
if p == nil || p.stopReap == nil {
|
||||
return nil
|
||||
}
|
||||
p.stopReap()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Mount reads the mcp.* keys and, when mcp.enabled is true, compiles every
|
||||
// plugin's MCP declaration against the host's route table, registers the
|
||||
// built-in backend guard provider, builds the session store and mounts
|
||||
|
||||
Reference in New Issue
Block a user