Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openrpc code generator #6

Open
despiegk opened this issue Dec 30, 2024 · 4 comments
Open

openrpc code generator #6

despiegk opened this issue Dec 30, 2024 · 4 comments
Assignees

Comments

@despiegk
Copy link
Contributor

minimal specs

  • start from a directory where there can be more than 1 openrpc spec
  • the name of the openrpc spec (name_fixed) will be the name of the actor
  • generate the intermediate code model spec representation in V
  • from this intermediate code mode spec generate openapi spec
  • from this intermediate code mode spec generate rest interface following this openapi spec
    • this interface calls the handlers which has the code to do the actions and crud
  • from this intermediate code mode spec generate openrpc interface using redis queues
    • this interface calls the handlers which has the code to do the actions and crud, which is same as above
  • from this intermediate code mode spec generate handlers in V, which is the code which executes the crud and actor.actions
  • generate example in .vsh to call the openrpc methods over redis

minimal requirements

  • each actor is a module in V
  • the models crud are in 1 file and autogenerated have _ at end of script, means user cannot overwrite
  • we create a model_modifier.v file which has hooks on each root object which are called in the models crud above
    • serialize (allows us to implement e.g. bin encoder), the default is just json
    • unserialize
    • index (called before saving, this is to put additional info in a chosen indexing method, default does nothing)
    • save_pre (called before saving), default does nothing
    • save_post (called after saving), default does nothing
  • each actor action is a separate file

crud generated code

  • index in sqlite
  • objects in ourdb (incremented int as id) using the serialize ... which means right now in json
@timurgordon
Copy link

Progress up to intermediate actor specification generation and generating handler and other specs from there. Working on porting progress from crystallib and moving required modules to hero lib in a working, tested and cleaned up way.

@timurgordon
Copy link

  • start from a directory where there can be more than 1 openrpc spec
  • the name of the openrpc spec (name_fixed) will be the name of the actor
  • generate the intermediate code model spec representation in V
  • from this intermediate code mode spec generate openapi spec

these above are fixed and exemplified with 7bc4da9, bada950, cbdc0fd

  • from this intermediate code mode spec generate rest interface following this openapi spec
  • this interface calls the handlers which has the code to do the actions and crud
  • from this intermediate code mode spec generate openrpc interface using redis queues
  • this interface calls the handlers which has the code to do the actions and crud, which is same as above
  • from this intermediate code mode spec generate handlers in V, which is the code which executes the crud and actor.actions
  • generate example in .vsh to call the openrpc methods over redis

progress for the above made with cbdc0fd, 5869998, ff8ee36. Architecture is ready and working, just need to match the generation to produce same outcomes.

once the handler generation for handling redis queue rpc's is complete, for which all the blockers have been resolved, will move on to crud method generation and ourdb generation to complete minimal requirements. Estimating to take a day each.

@timurgordon
Copy link

some overall fixes and improvements in modules used for baobab and actor generation: d49e94e , fa192e1, 6ba89a8

implemented compilation and test checking for code generation, so now we can ensure generated actor module compiles and the tests pass. We use this to also automate actor generation testing in baobab/generator/generate_actor_module_test.v

Also implemented the below requirements with a6ba22b, ce1ce72, d5af1d1, 357000e

  • from this intermediate code mode spec generate openrpc interface using redis queues
  • this interface calls the handlers which has the code to do the actions and crud, which is same as above
  • from this intermediate code mode spec generate handlers in V, which is the code which executes the crud and actor.actions

The openrpc interface and the http server is now being generated for actor. Next step is to demo this with example and tests. Then will move on to CRUD method generation and end to end examples. updated eta tuesday.

@timurgordon
Copy link

With c91f9ba and be1cee5, the generated actor module's OpenRPC handler now works, and can be interfaced over the posting JSONRPC requests to generated HTTP server's /openrpc endpoint.

to do so, the actor's rpc listener & handler must be run:

run_actor.vsh

#!/usr/bin/env -S v -w -n -enable-globals run
import pet_store_actor

mut actor := pet_store_actor.new()!
actor.run()!

and on a separate terminal session (due to some redis error spawning rpc handler and server wont work on the same vsh script)

run_http_server.vsh

#!/usr/bin/env -S v -w -n -enable-globals run
import pet_store_actor

pet_store_actor.run_http_server()!

right now, there seem to be timeout errors with generated handling of some methods, which need to be resolved with better logging / rpc tracking and more tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants