core.jobs.model #
fn new #
fn new() !&HeroRunner
new creates a new HeroRunner instance
enum AgentServiceState #
enum AgentServiceState {
ok // service/action is functioning normally
down // service/action is not available
error // service/action encountered an error
halted // service/action has been manually stopped
}
AgentServiceState represents the possible states of an agent service or action
enum AgentState #
enum AgentState {
ok // agent is functioning normally
down // agent is not responding
error // agent encountered an error
halted // agent has been manually stopped
}
AgentState represents the possible states of an agent
enum ServiceState #
enum ServiceState {
ok // service is functioning normally
down // service is not available
error // service encountered an error
halted // service has been manually stopped
}
ServiceState represents the possible states of a service
enum Status #
enum Status {
created // initial state
scheduled // job has been scheduled
planned // arrived where actor will execute the job
running // job is currently running
error // job encountered an error
ok // job completed successfully
}
Status represents the possible states of a job
struct ACE #
struct ACE {
pub mut:
groups []string // guid's of the groups who have access
users []string // in case groups are not used then is users
right string // e.g. read, write, admin, block
}
ACE represents an access control entry
struct ACL #
struct ACL {
pub mut:
name string
ace []ACE
}
ACL represents an access control list
struct Agent #
struct Agent {
pub mut:
pubkey string // pubkey using ed25519
address string // where we can find the agent
port int // default 9999
description string // optional
status AgentStatus
services []AgentService // these are the public services
signature string // signature as done by private key of $address+$port+$description+$status
}
Agent represents a service provider that can execute jobs
struct AgentManager #
struct AgentManager {
mut:
redis &redisclient.Redis
}
AgentManager handles all agent-related operations
fn (AgentManager) new #
fn (mut m AgentManager) new() Agent
new creates a new Agent instance
fn (AgentManager) set #
fn (mut m AgentManager) set(agent Agent) !
add adds a new agent to Redis
fn (AgentManager) get #
fn (mut m AgentManager) get(pubkey string) !Agent
get retrieves an agent by its public key
fn (AgentManager) list #
fn (mut m AgentManager) list() ![]Agent
list returns all agents
fn (AgentManager) delete #
fn (mut m AgentManager) delete(pubkey string) !
delete removes an agent by its public key
fn (AgentManager) update_status #
fn (mut m AgentManager) update_status(pubkey string, status AgentState) !
update_status updates just the status of an agent
fn (AgentManager) get_by_service #
fn (mut m AgentManager) get_by_service(actor string, action string) ![]Agent
get_by_service returns all agents that provide a specific service
struct AgentService #
struct AgentService {
pub mut:
actor string // name of the actor providing the service
actions []AgentServiceAction // available actions for this service
description string // optional description
status AgentServiceState // current state of the service
}
AgentService represents a service provided by an agent
struct AgentServiceAction #
struct AgentServiceAction {
pub mut:
action string // which action
description string // optional description
params map[string]string // e.g. name:'name of the vm' ...
params_example map[string]string // e.g. name:'myvm'
status AgentServiceState // current state of the action
public bool // if everyone can use then true, if restricted means only certain people can use
}
AgentServiceAction represents an action that can be performed by a service
struct AgentStatus #
struct AgentStatus {
pub mut:
guid string // unique id for the job
timestamp_first ourtime.OurTime // when agent came online
timestamp_last ourtime.OurTime // last time agent let us know that he is working
status AgentState // current state of the agent
}
AgentStatus represents the current state of an agent
struct Group #
struct Group {
pub mut:
guid string // unique id
name string // name of the group
description string // optional description
members []string // can be other group or member which is defined by pubkey
}
Group represents a collection of members (users or other groups)
struct GroupManager #
struct GroupManager {
mut:
redis &redisclient.Redis
}
GroupManager handles all group-related operations
fn (GroupManager) new #
fn (mut m GroupManager) new() Group
new creates a new Group instance
fn (GroupManager) set #
fn (mut m GroupManager) set(group Group) !
add adds a new group to Redis
fn (GroupManager) get #
fn (mut m GroupManager) get(guid string) !Group
get retrieves a group by its GUID
fn (GroupManager) list #
fn (mut m GroupManager) list() ![]Group
list returns all groups
fn (GroupManager) delete #
fn (mut m GroupManager) delete(guid string) !
delete removes a group by its GUID
fn (GroupManager) add_member #
fn (mut m GroupManager) add_member(guid string, member string) !
add_member adds a member (user pubkey or group GUID) to a group
fn (GroupManager) remove_member #
fn (mut m GroupManager) remove_member(guid string, member string) !
remove_member removes a member from a group
fn (GroupManager) get_user_groups #
fn (mut m GroupManager) get_user_groups(user_pubkey string) ![]Group
struct HeroRunner #
struct HeroRunner {
mut:
redis &redisclient.Redis
pub mut:
jobs &JobManager
agents &AgentManager
services &ServiceManager
groups &GroupManager
}
HeroRunner is the main factory for managing jobs, agents, services and groups
struct Job #
struct Job {
pub mut:
guid string // unique id for the job
agents []string // the pub key of the agent(s) which will execute the command, only 1 will execute
source string // pubkey from the agent who asked for the job
circle string = 'default' // our digital life is organized in circles
context string = 'default' // is the high level context in which actors will execute the work inside a circle
actor string // e.g. vm_manager
action string // e.g. start
params map[string]string // e.g. id:10
timeout_schedule u16 = 60 // timeout before its picked up
timeout u16 = 3600 // timeout in sec
log bool = true
ignore_error bool // means if error will just exit and not raise, there will be no error reporting
ignore_error_codes []int // of we want to ignore certain error codes
debug bool // if debug will get more context
retry int // default there is no debug
status JobStatus
dependencies []JobDependency // will not execute until other jobs are done
}
Job represents a task to be executed by an agent
struct JobDependency #
struct JobDependency {
pub mut:
guid string // unique id for the job
agents []string // the pub key of the agent(s) which can execute the command
}
JobDependency represents a dependency on another job
struct JobManager #
struct JobManager {
mut:
redis &redisclient.Redis
}
JobManager handles all job-related operations
fn (JobManager) new #
fn (mut m JobManager) new() Job
new creates a new Job instance
fn (JobManager) set #
fn (mut m JobManager) set(job Job) !
add adds a new job to Redis
fn (JobManager) get #
fn (mut m JobManager) get(guid string) !Job
get retrieves a job by its GUID
fn (JobManager) list #
fn (mut m JobManager) list() ![]Job
list returns all jobs
fn (JobManager) delete #
fn (mut m JobManager) delete(guid string) !
delete removes a job by its GUID
fn (JobManager) update_status #
fn (mut m JobManager) update_status(guid string, status Status) !
update_status updates just the status of a job
struct JobStatus #
struct JobStatus {
pub mut:
guid string // unique id for the job
created ourtime.OurTime // when we created the job
start ourtime.OurTime // when the job needs to start
end ourtime.OurTime // when the job ended, can be in error
status Status // current status of the job
}
JobStatus represents the current state of a job
struct Service #
struct Service {
pub mut:
actor string // name of the actor providing the service
actions []ServiceAction // available actions for this service
description string // optional description
status ServiceState // current state of the service
acl ?ACL // access control list for the service
}
Service represents a service that can be provided by agents
struct ServiceAction #
struct ServiceAction {
pub mut:
action string // which action
description string // optional description
params map[string]string // e.g. name:'name of the vm' ...
params_example map[string]string // e.g. name:'myvm'
acl ?ACL // if not used then everyone can use
}
ServiceAction represents an action that can be performed by a service
struct ServiceManager #
struct ServiceManager {
mut:
redis &redisclient.Redis
}
ServiceManager handles all service-related operations
fn (ServiceManager) new #
fn (mut m ServiceManager) new() Service
new creates a new Service instance
fn (ServiceManager) set #
fn (mut m ServiceManager) set(service Service) !
add adds a new service to Redis
fn (ServiceManager) get #
fn (mut m ServiceManager) get(actor string) !Service
get retrieves a service by its actor name
fn (ServiceManager) list #
fn (mut m ServiceManager) list() ![]Service
list returns all services
fn (ServiceManager) delete #
fn (mut m ServiceManager) delete(actor string) !
delete removes a service by its actor name
fn (ServiceManager) update_status #
fn (mut m ServiceManager) update_status(actor string, status ServiceState) !
update_status updates just the status of a service
fn (ServiceManager) get_by_action #
fn (mut m ServiceManager) get_by_action(action string) ![]Service
get_by_action returns all services that provide a specific action
fn (ServiceManager) check_access #
fn (mut m ServiceManager) check_access(actor string, action string, user_pubkey string, groups []string) !bool
check_access verifies if a user has access to a service action
- fn new
- enum AgentServiceState
- enum AgentState
- enum ServiceState
- enum Status
- struct ACE
- struct ACL
- struct Agent
- struct AgentManager
- struct AgentService
- struct AgentServiceAction
- struct AgentStatus
- struct Group
- struct GroupManager
- struct HeroRunner
- struct Job
- struct JobDependency
- struct JobManager
- struct JobStatus
- struct Service
- struct ServiceAction
- struct ServiceManager