Skip to content

Commit

Permalink
Merge pull request #4 from sdairs/rewrite
Browse files Browse the repository at this point in the history
fix issues from rewrite
  • Loading branch information
sdairs authored Dec 10, 2024
2 parents fc5f8d5 + aa448c7 commit d4648aa
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 1,142 deletions.
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@clickhouse/client": "^0.2.7",
"@oclif/core": "^3.15.1",
"@skyware/jetstream": "^1.0.0",
"@skyware/jetstream": "^0.2.1",
"kafkajs": "^2.2.4"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions apps/cli/src/commands/start/clickhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class StartClickhouse extends BaseStartCommand<typeof StartClickh
database: flags.database,
username: flags.username,
password: flags.password,
tableName: flags.table,
});
}, flags.table);
}
}
27 changes: 4 additions & 23 deletions apps/cli/src/destinations/clickhouse/clickhouse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Destination } from '../base.js';
import { createClient, ClickHouseClient, ClickHouseSettings, CommandResult } from '@clickhouse/client';
import { createClient, ClickHouseClient, ClickHouseSettings } from '@clickhouse/client';

interface ClickHouseConfig {
url: string;
Expand All @@ -8,14 +8,6 @@ interface ClickHouseConfig {
password: string;
}

interface ClickHouseDestinationConfig {
url?: string;
database?: string;
username?: string;
password?: string;
tableName: string;
}

const TABLE_DEFINITION = `
CREATE TABLE IF NOT EXISTS {table_name} (
capture_time DateTime,
Expand All @@ -32,20 +24,9 @@ export class ClickHouseDestination extends Destination {
private insertPromises: Promise<any>[];
private monitorInterval?: NodeJS.Timeout;

constructor({
url = 'http://localhost:8123',
database = 'default',
username = 'default',
password = '',
tableName,
}: ClickHouseDestinationConfig) {
constructor(config: ClickHouseConfig, tableName: string) {
super();
this.config = {
url,
database,
username,
password,
};
this.config = config;
this.tableName = tableName;
this.client = null;
this.insertPromises = [];
Expand All @@ -62,7 +43,7 @@ export class ClickHouseDestination extends Destination {
};

this.client = createClient({
url: this.config.url,
host: this.config.url,
database: this.config.database,
username: this.config.username,
password: this.config.password,
Expand Down
Loading

0 comments on commit d4648aa

Please sign in to comment.