update example and execution

This commit is contained in:
Timur Gordon
2025-08-26 17:16:01 +02:00
parent 010ecc7c71
commit 4958cd68c2
7 changed files with 171 additions and 240 deletions

View File

@@ -1,34 +1,39 @@
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
import time
import freeflowuniverse.herolib.baobab.runner
import herocode.runner
import freeflowuniverse.herolib.core.redisclient
const namespace = ''
const namespace = 'example'
mut r := &runner.Runner{
name: 'test_runner'
redis_conn: redisclient.new('127.0.0.1:6379')!
name: 'example_runner'
namespace: namespace
client: &runner.Client{
redis_conn: redisclient.new('127.0.0.1:6379')!
}
}
spawn r.run()
// job := runner.Job{
// id: 'test_job_1'
// caller_id: 'test_caller'
// context_id: 'test_context_1'
// runner: 'test_runner'
// executor: 'tmux.session1'
// payload: 'sleep 10\necho "Hello from job 1"\nsleep 10'
// status: .dispatched
// timeout: 30
// created_at: time.now()
// updated_at: time.now()
// }
job := runner.Job{
id: 'test_job_1'
caller_id: 'test_caller'
context_id: 'test_context_1'
runner: 'test_runner'
executor: 'tmux.session1'
payload: '!!git.list'
status: .dispatched
timeout: 30
created_at: time.now()
updated_at: time.now()
}
// mut redis_conn := redisclient.new('127.0.0.1:6379')!
// job.store_in_redis(mut redis_conn, namespace)!
// mut runner_q := redis_conn.queue_get(r.queue_key()!)
// runner_q.add(job.id)!
mut client := runner.Client{
redis_conn: redisclient.new('127.0.0.1:6379')!
}
client.store_in_redis(job.id, job)!
mut runner_q := client.redis_conn.queue_get(r.queue_key()!)
runner_q.add(job.id)!
for {}