DATA MODULE OCAML "some-module"
TABLE test_table {
id INT PRIMARY KEY,
some_text TEXT DEFAULT 'hello',
}
open! Context
open! Db_types
let define_data () =
mk_test_table ~id:123 () |> def_test_table;
mk_test_table ~id:123 ~some_text:"overriden" () |> def_test_table;
()
TABLE server {
hostname TEXT PRIMARY KEY,
}
TABLE server_volume {
volume_name TEXT PRIMARY KEY CHILD OF server,
mountpoint TEXT,
}
DATA server(hostname) {
server-a WITH server_volume {
pgtest1, '/srv/volumes/pgtest1';
};
server-b WITH server_volume {
pgtest1, '/srv/volumes/pgtest1';
};
}
TABLE db_deployment {
deployment_name TEXT PRIMARY KEY,
}
TABLE db_deployment_instance {
deployment_id INT PRIMARY KEY CHILD OF db_deployment,
db_server REF FOREIGN CHILD server_volume,
CHECK { deployment_id > 0 },
}
DATA STRUCT db_deployment [
{
deployment_name: foo WITH db_deployment_instance [
{
deployment_id: 1,
db_server: server-a=>pgtest1,
},
{
deployment_id: 2,
db_server: server-b=>pgtest1,
},
]
}
]
TABLE server {
hostname TEXT PRIMARY KEY,
ssh_interface REF CHILD network_interface,
}
TABLE network {
network_name TEXT PRIMARY KEY,
cidr TEXT,
}
TABLE network_interface {
if_name TEXT PRIMARY KEY CHILD OF server,
if_network REF network,
if_ip TEXT,
if_subnet_mask_cidr INT,
}
DATA STRUCT network [
{
network_name: lan,
cidr: '10.16.0.0/12',
}
]
DATA server(hostname, ssh_interface) {
server-a, eth0 WITH network_interface {
eth0, lan, 10.17.0.10, 24;
};
}
TABLE existant_parent {
some_key TEXT PRIMARY KEY,
spec_child REF CHILD existant_child_2,
}
TABLE existant_child {
some_child_key TEXT PRIMARY KEY CHILD OF existant_parent,
}
TABLE existant_child_2 {
some_child_key_2 TEXT PRIMARY KEY CHILD OF existant_child,
}
DATA existant_parent {
outer_val, inner_val=>henloz WITH existant_child {
inner_val WITH existant_child_2 {
henlo
}
}
}
TABLE server {
hostname TEXT PRIMARY KEY,
tld REF tld DETACHED DEFAULT,
fqdn TEXT GENERATED AS { hostname .. "." .. tld },
}
TABLE tld {
domain TEXT PRIMARY KEY,
}
DEFAULTS {
// defines default for table 'server' and column 'tld'.
// you cannot define defaults for non existing tables
// and column must be marked as detached default
server.tld epl-infra.net,
}
// now we can define data with detached default
DATA STRUCT server {
hostname: server-a
}
DATA tld {
epl-infra.net;
}
| application | monitoring | database access | queues | logging | proxying | load balancing | .. | feature 1000th |
|-------------+------------+-----------------+--------+---------+----------+----------------+----+----------------|
| app 1 | | | | | | | | |
| app 2 | | | | | | | | |
| app 3 | | | | | | | | |
| ... | | | | | | | | |
| app 1000th | | | | | | | | |