| 24 | ) |
| 25 | |
| 26 | func NewRuntimeInfo(params *NewRuntimeParameters) *RuntimeInfo { |
| 27 | ri := &RuntimeInfo{ |
| 28 | RuntimeID: params.RuntimeID, |
| 29 | LastAccessTime: time.Now(), |
| 30 | LastLivenessTime: time.Now(), |
| 31 | ConcurrentMode: params.ConcurrentMode, |
| 32 | DefaultConcurrentMode: params.ConcurrentMode, |
| 33 | Abnormal: false, |
| 34 | State: RuntimeStateClosed, |
| 35 | runtimeRunChan: make(chan struct{}), |
| 36 | runtimeStopChan: make(chan struct{}), |
| 37 | runtimeStoppingChan: make(chan struct{}), |
| 38 | requestChan: make(chan *InvokeRequest, 100), // TODO: length is a magic num |
| 39 | httpClient: nil, |
| 40 | runtimeWaitGroup: sync.WaitGroup{}, |
| 41 | WaitRuntimeAliveTimeout: params.WaitRuntimeAliveTimeout, |
| 42 | WithStreamMode: params.StreamMode, |
| 43 | Resource: params.Resource, |
| 44 | } |
| 45 | if params.IsFrozen { |
| 46 | ri.SetState(RuntimeStateMerged) |
| 47 | } |
| 48 | return ri |
| 49 | } |
| 50 | |
| 51 | func (info *RuntimeInfo) SetState(s RuntimeStateType) { |
| 52 | logs.V(3).Infof("update runtime %s state %s to %s", info.RuntimeID, info.State, s) |