mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	| @@ -12,16 +12,18 @@ type contextKeyType struct{} | ||||
|  | ||||
| var contextKey contextKeyType | ||||
|  | ||||
| // UpdateFuncInfo updates a context's func info | ||||
| func UpdateFuncInfo(ctx context.Context, funcInfo *FuncInfo) { | ||||
| 	record, ok := ctx.Value(contextKey).(*requestRecord) | ||||
| 	if !ok { | ||||
| 		return | ||||
| 	} | ||||
| // RecordFuncInfo records a func info into context | ||||
| func RecordFuncInfo(ctx context.Context, funcInfo *FuncInfo) (end func()) { | ||||
| 	// TODO: reqCtx := reqctx.FromContext(ctx), add trace support | ||||
| 	end = func() {} | ||||
|  | ||||
| 	record.lock.Lock() | ||||
| 	record.funcInfo = funcInfo | ||||
| 	record.lock.Unlock() | ||||
| 	// save the func info into the context record | ||||
| 	if record, ok := ctx.Value(contextKey).(*requestRecord); ok { | ||||
| 		record.lock.Lock() | ||||
| 		record.funcInfo = funcInfo | ||||
| 		record.lock.Unlock() | ||||
| 	} | ||||
| 	return end | ||||
| } | ||||
|  | ||||
| // MarkLongPolling marks the request is a long-polling request, and the logger may output different message for it | ||||
|   | ||||
		Reference in New Issue
	
	Block a user