mirror of
https://github.com/dragonheim/gagent.git
synced 2025-01-18 09:36:28 -08:00
35 lines
583 B
Go
35 lines
583 B
Go
package gstructs
|
|
|
|
import (
|
|
fmt "fmt"
|
|
)
|
|
|
|
type AgentStatus []string
|
|
|
|
var AgentStatuses = AgentStatus{
|
|
"ERROR",
|
|
"INIT",
|
|
"SENDING",
|
|
"RECEIVING",
|
|
"ROUTING",
|
|
"PROCESSING",
|
|
"COMPLETED",
|
|
"RETURNING",
|
|
"ERROR",
|
|
}
|
|
|
|
func (a AgentStatus) GetByIndex(index int) (string, error) {
|
|
if index < 0 || index >= len(a) {
|
|
return "", fmt.Errorf("invalid index: %d", index)
|
|
}
|
|
return a[index], nil
|
|
}
|
|
|
|
func (a AgentStatus) GetByName(name string) (byte, error) {
|
|
for i, status := range a {
|
|
if status == name {
|
|
return byte(i), nil
|
|
}
|
|
}
|
|
return 0, fmt.Errorf("value not found: %s", name)
|
|
}
|