Skip to content

Commit

Permalink
rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
killua-eu committed Jan 22, 2024
1 parent 18059d6 commit a8193df
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 61 deletions.
12 changes: 6 additions & 6 deletions glued/Config/Migrations/20231009002534_actions.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
-- migrate:up

CREATE TABLE `t_if__actions` (
`c_svc_uuid` binary(16) NOT NULL COMMENT 'IF instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)',
`c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF action uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)',
`c_service_uuid` binary(16) NOT NULL COMMENT 'IF service UUID',
`c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF action uuid (v4)',
`c_data` json NOT NULL COMMENT 'JSON data',
`c_type` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.type'))) STORED COMMENT '[STORED] Interface Framework action type',
`c_scheme` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.scheme'))) STORED COMMENT '[STORED] Interface Framework action scheme',
`c_note` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.note'))) STORED COMMENT '[STORED] Interface Framework action note',
`c_freq` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.freq'))) STORED COMMENT '[STORED] Interface Framework action frequency',
PRIMARY KEY (`c_uuid`),
UNIQUE KEY `uniq_svc_uuid_type` (`c_svc_uuid`,`c_type`),
KEY `idx_svc_uuid` (`c_svc_uuid`),
KEY `idx_type` (`c_type`)
UNIQUE KEY `uniq_service_scheme` (`c_service_uuid`,`c_scheme`),
KEY `idx_service` (`c_service_uuid`),
KEY `idx_scheme` (`c_scheme`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instance actions.';

-- migrate:down
Expand Down
19 changes: 0 additions & 19 deletions glued/Config/Migrations/20231009002540_logs.sql

This file was deleted.

19 changes: 19 additions & 0 deletions glued/Config/Migrations/20231009002540_runs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- migrate:up

CREATE TABLE `t_if__runs` (
`c_action_uuid` binary(16) NOT NULL COMMENT 'IF action UUID',
`c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF run UUID',
`c_data` json NOT NULL COMMENT 'JSON response body',
`c_ts_start` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp: run started',
`c_ts_finish` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp: run finished',
`c_status` varchar(32) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL COMMENT 'Integration run status: init, ok, fail, skip',
`c_hash` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'Response data hash',
`c_fid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Response foreign identifier',
PRIMARY KEY (`c_uuid`),
KEY `idx_act_uuid` (`c_action_uuid`),
KEY `idx_response_hash` (`c_hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service logs.';

-- migrate:down

DROP TABLE IF EXISTS `t_if__runs`;
10 changes: 5 additions & 5 deletions glued/Config/Migrations/20231009002603_services.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ CREATE TABLE `t_if__services` (
`c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'IF service instance uuid (v4), autogenerated on SQL insert if not provided. NOTE to always insert with UUID_TO_BIN(UUID(), true)',
`c_data` json NOT NULL COMMENT 'JSON data',
`c_hash` varchar(32) GENERATED ALWAYS AS (md5(`c_data`)) STORED COMMENT '[STORED] MD5 Hash of the data json (acting as a unique index)',
`c_type` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.type'))) STORED COMMENT '[STORED] Interface Framework service type',
`c_name` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.name'))) STORED COMMENT '[STORED] Interface Framework service deployment name',
`c_host` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.host'))) STORED COMMENT '[STORED] Interface Framework remote host',
`c_service` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.service'))) STORED COMMENT '[STORED] Interface Framework service service',
`c_remote` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.remote'))) STORED COMMENT '[STORED] Interface Framework remote remote',
`c_deployment` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.deployment'))) STORED COMMENT '[STORED] Interface Framework service deployment name',
`c_note` varchar(255) GENERATED ALWAYS AS (json_unquote(json_extract(`c_data`,_utf8mb4'$.note'))) STORED COMMENT '[STORED] Interface Framework remote note',
PRIMARY KEY (`c_uuid`),
UNIQUE KEY `c_hash` (`c_hash`),
KEY `idx_type` (`c_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instances (service / remote host / authentication).';
KEY `idx_service` (`c_service`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='Integration framework service instances (service / remote remote / authentication).';

-- migrate:down

Expand Down

This file was deleted.

20 changes: 20 additions & 0 deletions glued/Config/Migrations/20240122164828_objects.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- migrate:up

CREATE TABLE `t_if__objects` (
`c_uuid` binary(16) NOT NULL DEFAULT (uuid_to_bin(uuid(),true)) COMMENT 'Object UUID',
`c_action` binary(16) NOT NULL COMMENT 'Action UUID (infer action scheme, service, and service deployment)',
`c_fid` varchar(255) NOT NULL COMMENT 'JSON data object foreign unique identifier',
`c_rev` int unsigned DEFAULT '0' COMMENT 'JSON data object revision number',
`c_iat` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp of issuance',
`c_uat` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Timestamp of update',
`c_data` json DEFAULT NULL,
`c_hash` binary(16) GENERATED ALWAYS AS (unhex(md5(`c_data`))) STORED COMMENT 'MD5 hash of c_data',
`c_run` binary(16) DEFAULT NULL COMMENT 'Response UUID (infer run hash and run fid)',
PRIMARY KEY (`c_uuid`),
UNIQUE KEY `unique_action_fid` (`c_action`,`c_fid`),
KEY `idx_c_action` (`c_action`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- migrate:down

DROP TABLE IF EXISTS `t_if__objects`;
24 changes: 12 additions & 12 deletions glued/Config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ routes:
#########################################################

be_if_health_v1:
pattern: ${routes.be_if.path}/health/v1
path: ${routes.be_if.path}/health/v1
pattern: ${routes.be_if.path}/v1/health
path: ${routes.be_if.path}/v1/health
label: if health
dscr: A healthcheck endpoint for the integration framework microservice.
service: IF
Expand All @@ -31,8 +31,8 @@ routes:
#########################################################

be_if_services_v1:
pattern: ${routes.be_if.path}/services/v1
path: ${routes.be_if.path}/services/v1
pattern: ${routes.be_if.path}/v1/services
path: ${routes.be_if.path}/v1/services
label: IF Services
dscr: People-friendly navigation.
service: if
Expand All @@ -41,35 +41,35 @@ routes:
post: Glued\Controllers\IfController:services_c1

be_if_queue_v1:
pattern: ${routes.be_if.path}/queue/v1
path: ${routes.be_if.path}/queue/v1
pattern: ${routes.be_if.path}/v1/queue
path: ${routes.be_if.path}/v1/queue
label: IF Queue
dscr: Interface queue
service: if
methods:
get: Glued\Controllers\IfController:queue_r1

be_if_stats_v1:
pattern: ${routes.be_if.path}/stats/v1
path: ${routes.be_if.path}/stats/v1
pattern: ${routes.be_if.path}/v1/stats
path: ${routes.be_if.path}/v1/stats
label: IF Statistics
dscr: Interface statistics
service: if
methods:
get: Glued\Controllers\IfController:stats_r1

be_if_logs_v1:
pattern: ${routes.be_if.path}/logs/v1
path: ${routes.be_if.path}/logs/v1
pattern: ${routes.be_if.path}/v1/logs
path: ${routes.be_if.path}/v1/logs
label: IF Logs
dscr: Interface logs
service: if
methods:
get: Glued\Controllers\IfController:logs_r1

be_if_reg_v1:
pattern: ${routes.be_if.path}/reg/v1
path: ${routes.be_if.path}/reg/v1
pattern: ${routes.be_if.path}/v1/reg
path: ${routes.be_if.path}/v1/reg
label: IF Register
dscr: Interface action register
service: if
Expand Down
8 changes: 4 additions & 4 deletions glued/Controllers/IfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function queue_r1(Request $request, Response $response, array $args = [])
$r = $this->mysqli->execute_query($qs,array_values($rp));
$res['status'] = 'ok';
foreach ($r as $i) {
$i['run'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/svc/' . $i['svc_type'] . '/act/v1?act_uuid=' . $i['act_uuid'];
$i['log'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/logs/v1?act_uuid=' . $i['act_uuid'];
$i['run'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/v1/svc/' . $i['svc_type'] . '/act/' . $i['act_uuid'];
$i['log'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/v1/logs/' . $i['act_uuid'];
$res['data'][] = $i;
}
return $response->withJson($res);
Expand All @@ -122,8 +122,8 @@ public function reg_r1(Request $request, Response $response, array $args = []):
$r = $this->mysqli->execute_query($qs,array_values($rp));
$res['status'] = 'ok';
foreach ($r as $i) {
$i['run'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/svc/' . $i['svc_type'] . '/act/v1?act_uuid=' . $i['act_uuid'];
$i['log'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/logs/v1?act_uuid=' . $i['act_uuid'];
$i['run'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/v1/svc/' . $i['svc_type'] . '/act/' . $i['act_uuid'];
$i['log'] = $this->settings['glued']['protocol'] . $this->settings['glued']['hostname'] . '/api/if/v1/logs/' . $i['act_uuid'];
$res['data'][] = $i;
}
return $response->withJson($res);
Expand Down
7 changes: 3 additions & 4 deletions glued/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
return $response->withStatus(204);
})->setName('fallback_options');


foreach ($settings['routes'] as $name => $leaf) {
if (isset($leaf['methods'])) {
foreach ($leaf['methods'] as $request => $method) {
$route = $app->$request($leaf['path'], $method);
$route = $route->setName($name);
}
$route = $app->$request($leaf['pattern'], $method);
$route = $route->setName($name);
}
}
}

Expand Down

0 comments on commit a8193df

Please sign in to comment.