mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
docs: add comprehensive documentation and fix SSE graceful shutdown
- Created a detailed \`docs\` directory with Chinese documentation for all major features. - Implemented \`BaseContext\` propagation in \`Engine\` to allow long-lived connections (like SSE) to receive shutdown signals. - Added \`Engine.Context()\` to provide access to the shutdown context. - Updated \`docs/sse.md\` with a guide on handling graceful shutdowns. - Cleaned up temporary build/update scripts. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
parent
1066a9b1cf
commit
2e55db4e2d
3 changed files with 37 additions and 0 deletions
16
serve.go
16
serve.go
|
|
@ -224,7 +224,11 @@ func (engine *Engine) RunShutdown(addr string, timeouts ...time.Duration) error
|
|||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: engine,
|
||||
BaseContext: func(l net.Listener) context.Context {
|
||||
return engine.shutdownCtx
|
||||
},
|
||||
}
|
||||
srv.RegisterOnShutdown(engine.shutdownCancel)
|
||||
|
||||
// 应用框架的默认配置和用户提供的自定义配置
|
||||
//engine.applyDefaultServerConfig(srv)
|
||||
|
|
@ -241,7 +245,11 @@ func (engine *Engine) RunShutdownWithContext(addr string, ctx context.Context, t
|
|||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: engine,
|
||||
BaseContext: func(l net.Listener) context.Context {
|
||||
return engine.shutdownCtx
|
||||
},
|
||||
}
|
||||
srv.RegisterOnShutdown(engine.shutdownCancel)
|
||||
|
||||
// 应用框架的默认配置和用户提供的自定义配置
|
||||
//engine.applyDefaultServerConfig(srv)
|
||||
|
|
@ -270,7 +278,11 @@ func (engine *Engine) RunTLS(addr string, tlsConfig *tls.Config, timeouts ...tim
|
|||
Addr: addr,
|
||||
Handler: engine,
|
||||
TLSConfig: tlsConfig,
|
||||
BaseContext: func(l net.Listener) context.Context {
|
||||
return engine.shutdownCtx
|
||||
},
|
||||
}
|
||||
srv.RegisterOnShutdown(engine.shutdownCancel)
|
||||
|
||||
// 应用框架的默认配置和用户提供的自定义配置
|
||||
// 优先使用 TLSServerConfigurator,如果未设置,则回退到通用的 ServerConfigurator
|
||||
|
|
@ -304,7 +316,11 @@ func (engine *Engine) RunTLSRedir(httpAddr, httpsAddr string, tlsConfig *tls.Con
|
|||
Addr: httpsAddr,
|
||||
Handler: engine,
|
||||
TLSConfig: tlsConfig,
|
||||
BaseContext: func(l net.Listener) context.Context {
|
||||
return engine.shutdownCtx
|
||||
},
|
||||
}
|
||||
httpsSrv.RegisterOnShutdown(engine.shutdownCancel)
|
||||
//engine.applyDefaultServerConfig(httpsSrv)
|
||||
if engine.TLSServerConfigurator != nil {
|
||||
engine.TLSServerConfigurator(httpsSrv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue