This is a Command Line Interface to interact with Omnigres. Also check the Omnigres documentation for more info about the platform.
In order to provision an Omnigres cluster you should have the Docker CLI installed. Check their Get Started page to install the Docker tools on your system.
Download binaries from the releases page for your architecture and place within your PATH. Then try calling it without parameters
omnigres
This will show a list of all available commands.
To create an application from scratch start using the init command. But we should start in a new root directory for your Omnigres projects.
mkdir og_projects
cd og_projects
omnigres init first_app
Now run the server with omnigres start
.
omnigres start
You should see all the available endpoints once the command finishes.
INFO Omnigres Orb cluster started.
omnigres (Postgres): postgres://omnigres:omnigres@172.19.0.3:5432/omnigres
omnigres (HTTP): http://172.19.0.3:8081
You should have now a first_app/src
directory. We can place a little function and router there.
Just copy the contents below into first_app/src/hello.sql
.
create extension omni_httpd cascade;
create function my_handler(request omni_httpd.http_request)
returns omni_httpd.http_outcome
return omni_httpd.http_response(body => 'Hello World');
create table my_router (like omni_httpd.urlpattern_router);
insert into my_router (match, handler)
values (omni_httpd.urlpattern('/'), 'my_handler'::regproc);
After saving the file you can create the application using the command assemble
.
This will build a new database (also called Orb in this context) named first_app using the contents of first_app/src
.
omnigres assemble
Now check your current endpoints using the endpoints
command.
omnigres endpoints
The result should be similar to the one below. Note that the IP addresses and ports might differ.
omnigres (Postgres): postgres://omnigres:omnigres@172.19.0.3:5432/omnigres
omnigres (HTTP): http://172.19.0.3:8081
first_app (Postgres): postgres://omnigres:omnigres@172.19.0.3:5432/first_app
first_app (HTTP): http://172.19.0.3:8080
Open the HTTP address in your browser for first_app
, and you should see the message 'Hello, world!'
To stop the service just use the stop
command.
omnigres stop
First ensure you have a working go development environment.
go build -o omnigres cmd/omnigres/main.go
The command above should compile a binary omnigres
at the project's root folder.