Skip to content
Discussion options

You must be logged in to vote
module main

import veb
import sync
import os
import time

// ------------------ 上下文结构体 ------------------
pub struct Context {
	veb.Context
}

// ------------------ 应用结构体 ------------------
pub struct App {
	veb.Middleware[Context]
	veb.Controller
	veb.StaticHandler
pub mut:
	started       chan bool  // 服务已启动信号(未使用,但保留)
	shutdown_ch   chan bool  // 接收关闭请求的通道
	inflight      int        // 当前正在处理的请求数量
	shutting_down bool       // 标记是否正在关闭中
	mu            sync.Mutex // 保护 inflight 和 shutting_down 的互斥锁
	inflight_zero chan bool  // 当 inflight 变为 0 时发送通知
	admin_token   string     // 管理员令牌,用于触发 HTTP 关机(与 Authorization header 比对)
	// 配置
	shutdown_wait_secs int // 最长等待正在处理请求完成的秒数
}

// -----------…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Avey777
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant