mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: add container state to eviction stats (#1296)
This commit is contained in:
@@ -25,6 +25,7 @@ type requestState struct {
|
||||
|
||||
type ContainerState interface {
|
||||
UpdateState(ctx context.Context, newState ContainerStateType, slots *slotQueue)
|
||||
GetState() string
|
||||
}
|
||||
type RequestState interface {
|
||||
UpdateState(ctx context.Context, newState RequestStateType, slots *slotQueue)
|
||||
@@ -57,6 +58,16 @@ const (
|
||||
ContainerStateMax
|
||||
)
|
||||
|
||||
var containerStateKeys = [ContainerStateMax]string{
|
||||
"none",
|
||||
"wait",
|
||||
"start",
|
||||
"idle",
|
||||
"paused",
|
||||
"busy",
|
||||
"done",
|
||||
}
|
||||
|
||||
var containerGaugeKeys = [ContainerStateMax]string{
|
||||
"",
|
||||
"container_wait_total",
|
||||
@@ -108,6 +119,16 @@ func isIdleState(state ContainerStateType) bool {
|
||||
return state == ContainerStateIdle || state == ContainerStatePaused
|
||||
}
|
||||
|
||||
func (c *containerState) GetState() string {
|
||||
var res ContainerStateType
|
||||
|
||||
c.lock.Lock()
|
||||
res = c.state
|
||||
c.lock.Unlock()
|
||||
|
||||
return containerStateKeys[res]
|
||||
}
|
||||
|
||||
func (c *containerState) UpdateState(ctx context.Context, newState ContainerStateType, slots *slotQueue) {
|
||||
|
||||
var now time.Time
|
||||
|
||||
Reference in New Issue
Block a user