1// Copyright 2021 The Gitea Authors. All rights reserved.
2// SPDX-License-Identifier: MIT
3
4package process
5
6import (
7 "context"
8 "runtime/trace"
9 "time"
10)
11
12var (
13 SystemProcessType = "system"
14 RequestProcessType = "request"
15 GitProcessType = "git"
16 NormalProcessType = "normal"
17 NoneProcessType = "none"
18)
19
20// process represents a working process inheriting from Gitea.
21type process struct {
22 PID IDType // Process ID, not system one.
23 ParentPID IDType
24 Description string
25 Start time.Time
26 Cancel context.CancelFunc
27 Type string
28 TraceTrask *trace.Task
29}
30
31// ToProcess converts a process to a externally usable Process
32func (p *process) toProcess() *Process {
33 process := &Process{
34 PID: p.PID,
35 ParentPID: p.ParentPID,
36 Description: p.Description,
37 Start: p.Start,
38 Type: p.Type,
39 }
40 return process
41}