Skip to content

Commit

Permalink
inference-gateway FDW to queue instance (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHend authored Jul 10, 2024
1 parent 605012f commit 3eefc6b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions inference-gateway/migrations/20240626175841_fdw.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
CREATE EXTENSION IF NOT EXISTS pg_cron;

CREATE SERVER IF NOT EXISTS cp_queue_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host 'localhost', port '5432', dbname 'postgres');

CREATE USER MAPPING IF NOT EXISTS FOR postgres
SERVER cp_queue_server
OPTIONS (user 'postgres', password 'postgres');

CREATE FOREIGN TABLE IF NOT EXISTS fdw_paid_organizations (
organization_id text NOT NULL,
has_cc boolean not null default false,
last_updated_at timestamp with time zone not null default now()
)
SERVER cp_queue_server
OPTIONS (schema_name 'billing', table_name 'paid_organizations');

SELECT cron.schedule('refresh-validations', '* * * * *', $$
BEGIN;
TRUNCATE inference.org_validation;
INSERT INTO inference.org_validation
SELECT
organization_id as org_id,
has_cc as valid,
now() as last_updated_at
FROM fdw_paid_organizations;
COMMIT;
$$);
1 change: 1 addition & 0 deletions inference-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::time::Duration;
#[actix_web::main]
async fn main() {
env_logger::init();

let cfg = gateway::config::Config::new().await;
let startup_configs = gateway::server::webserver_startup_config(cfg).await;
let server_port = startup_configs.cfg.server_port;
Expand Down

0 comments on commit 3eefc6b

Please sign in to comment.