fixes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -w -n -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.baobab.generator
|
||||
import freeflowuniverse.herolib.baobab.specification
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -w -n -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.baobab.generator
|
||||
import freeflowuniverse.herolib.baobab.specification
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env -S v -w -n -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.baobab.generator
|
||||
import freeflowuniverse.herolib.baobab.specification
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
methods.v
|
||||
meeting_scheduler_actor
|
||||
meeting_scheduler_actor
|
||||
generate_actor_module
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
#!/usr/bin/env -S v -w -n -enable-globals run
|
||||
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.baobab.generator
|
||||
import freeflowuniverse.herolib.baobab.specification
|
||||
import freeflowuniverse.herolib.schemas.openapi
|
||||
import os
|
||||
|
||||
|
||||
const example_dir = os.dir(@FILE)
|
||||
const openapi_spec_path = os.join_path(example_dir, 'openapi.json')
|
||||
|
||||
|
||||
// the actor specification obtained from the OpenRPC Specification
|
||||
openapi_spec := openapi.new(path: openapi_spec_path)!
|
||||
actor_spec := specification.from_openapi(openapi_spec)!
|
||||
|
||||
println(actor_spec)
|
||||
|
||||
actor_module := generator.generate_actor_module(
|
||||
actor_spec,
|
||||
interfaces: [.openapi, .http]
|
||||
)!
|
||||
|
||||
actor_module.write(example_dir,
|
||||
format: true
|
||||
format: false
|
||||
overwrite: true
|
||||
compile: true
|
||||
compile: false
|
||||
)!
|
||||
|
||||
os.execvp('bash', ['${example_dir}/meeting_scheduler_actor/scripts/run.sh'])!
|
||||
@@ -1,33 +0,0 @@
|
||||
import os
|
||||
import freeflowuniverse.herolib.baobab.stage {IActor, RunParams}
|
||||
import freeflowuniverse.herolib.schemas.openapi
|
||||
|
||||
const openapi_spec_path = '@{dollar}{os.dir(@@FILE)}/specs/openapi.json'
|
||||
const openapi_spec_json = os.read_file(openapi_spec_path) or { panic(err) }
|
||||
const openapi_specification = openapi.json_decode(openapi_spec_json)!
|
||||
|
||||
struct @{actor_name_pascal}Actor {
|
||||
stage.Actor
|
||||
}
|
||||
|
||||
fn new() !@{actor_name_pascal}Actor {
|
||||
return @{actor_name_pascal}Actor {
|
||||
stage.new_actor('@{actor_name_snake}')
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run() ! {
|
||||
mut a_ := new()!
|
||||
mut a := IActor(a_)
|
||||
a.run()!
|
||||
}
|
||||
|
||||
pub fn run_server(params RunParams) ! {
|
||||
mut a := new()!
|
||||
mut server := actor.new_server(
|
||||
redis_url: 'localhost:6379'
|
||||
redis_queue: a.name
|
||||
openapi_spec: openapi_specification
|
||||
)!
|
||||
server.run(params)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
import freeflowuniverse.herolib.baobab.stage
|
||||
import freeflowuniverse.herolib.core.redisclient
|
||||
import freeflowuniverse.herolib.schemas.openapi
|
||||
import time
|
||||
|
||||
const name = '@{actor_name_snake}'
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash -ex
|
||||
|
||||
DIR="@{dollar}(cd "@{dollar}(dirname "@{dollar}{BASH_SOURCE[0]}")" && pwd)"
|
||||
echo "@{dollar}DIR"
|
||||
|
||||
chmod +x @{dollar}{DIR}/run_actor.vsh
|
||||
@{dollar}{DIR}/run_actor.vsh > /dev/null 2>&1 &
|
||||
@{dollar}{DIR}/run_actor.vsh &
|
||||
ACTOR_PID=@{dollar}!
|
||||
|
||||
chmod +x @{dollar}{DIR}/run_http_server.vsh
|
||||
@{dollar}{DIR}/run_http_server.vsh > /dev/null 2>&1 &
|
||||
@{dollar}{DIR}/run_http_server.vsh &
|
||||
HTTP_SERVER_PID=@{dollar}!
|
||||
|
||||
# Print desired output
|
||||
|
||||
@@ -5,6 +5,7 @@ import os
|
||||
|
||||
pub interface IFile {
|
||||
write(string, WriteOptions) !
|
||||
name string
|
||||
}
|
||||
|
||||
pub struct File {
|
||||
@@ -23,8 +24,7 @@ pub fn (f File) write(path string, params WriteOptions) ! {
|
||||
}
|
||||
|
||||
pub fn (f File) typescript(path string, params WriteOptions) ! {
|
||||
format := true
|
||||
if format {
|
||||
if params.format {
|
||||
os.execute('npx prettier --write ${path}')
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
module code
|
||||
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import os
|
||||
import log
|
||||
@@ -35,38 +35,48 @@ pub fn (mod Module) write(path string, options WriteOptions) ! {
|
||||
path: if mod.in_src { '${path}/${mod.name}/src' } else { '${path}/${mod.name}' }
|
||||
empty: options.overwrite
|
||||
)!
|
||||
console.print_debug("write ${module_dir.path}")
|
||||
// pre:="v -n -w -enable-globals"
|
||||
pre:="v -n -w -gc none -cc tcc -d use_openssl -enable-globals run"
|
||||
|
||||
if !options.overwrite && module_dir.exists() {
|
||||
return
|
||||
}
|
||||
|
||||
for file in mod.files {
|
||||
console.print_debug("mod file write ${file.name}")
|
||||
file.write(module_dir.path, options)!
|
||||
}
|
||||
|
||||
for folder in mod.folders {
|
||||
console.print_debug("mod folder write ${folder.name}")
|
||||
folder.write('${path}/${mod.name}', options)!
|
||||
}
|
||||
|
||||
for mod_ in mod.modules {
|
||||
console.print_debug("mod write ${mod_.name}")
|
||||
mod_.write('${path}/${mod.name}', options)!
|
||||
}
|
||||
|
||||
if options.format {
|
||||
console.print_debug("format ${module_dir.path}")
|
||||
os.execute('v fmt -w ${module_dir.path}')
|
||||
}
|
||||
if options.compile {
|
||||
os.execute_opt('v -n -w -enable-globals -shared ${module_dir.path}') or {
|
||||
console.print_debug("compile shared ${module_dir.path}")
|
||||
os.execute_opt('${pre} -shared ${module_dir.path}') or {
|
||||
log.fatal(err.msg())
|
||||
}
|
||||
}
|
||||
if options.test {
|
||||
os.execute_opt('v -n -w -enable-globals test ${module_dir.path}') or {
|
||||
console.print_debug("test ${module_dir.path}")
|
||||
os.execute_opt('${pre} test ${module_dir.path}') or {
|
||||
log.fatal(err.msg())
|
||||
}
|
||||
}
|
||||
if options.document {
|
||||
docs_path := '${path}/${mod.name}/docs'
|
||||
console.print_debug("document ${module_dir.path}")
|
||||
os.execute('v doc -f html -o ${docs_path} ${module_dir.path}')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user