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

inference-gateway FDW to queue instance #860

Merged
merged 16 commits into from
Jul 10, 2024
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
Loading