From 424d2b9213c6bc0d25bb3c2e1768ce0241849283 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 26 Jan 2026 12:05:03 +0100 Subject: [PATCH] =?UTF-8?q?cLiEnT=20WAHBG=20JUSAGHEJWBFDRIOUASnaefhsbgktw?= =?UTF-8?q?=20jvskfgaehji=20bs=C5=A1u=C4=87af?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickhouse/client.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/clickhouse/client.go b/clickhouse/client.go index 013a7ff..2b95a03 100644 --- a/clickhouse/client.go +++ b/clickhouse/client.go @@ -14,13 +14,13 @@ import ( "github.com/ClickHouse/clickhouse-go/v2/lib/driver" ) -// Client wraps ClickHouse connection and operations -type Client struct { - conn driver.Conn +// ClickhouseClient wraps ClickHouse connection and operations +type ClickhouseClient struct { + Conn driver.Conn } // NewClient creates a new ClickHouse client using config -func NewClient() (*Client, error) { +func NewClient() (*ClickhouseClient, error) { options := &clickhouse.Options{ Addr: []string{config.ClickhouseHost}, Auth: clickhouse.Auth{ @@ -39,24 +39,24 @@ func NewClient() (*Client, error) { return nil, fmt.Errorf("failed to connect to ClickHouse: %w", err) } - return &Client{conn: conn}, nil + return &ClickhouseClient{Conn: conn}, nil } // Close closes the ClickHouse connection -func (c *Client) Close() error { - if c.conn != nil { - return c.conn.Close() +func (c *ClickhouseClient) Close() error { + if c.Conn != nil { + return c.Conn.Close() } return nil } // Query executes a SELECT query and returns the rows -func (c *Client) Query(ctx context.Context, query string, args ...interface{}) (driver.Rows, error) { - return c.conn.Query(ctx, query, args...) +func (c *ClickhouseClient) Query(ctx context.Context, query string, args ...interface{}) (driver.Rows, error) { + return c.Conn.Query(ctx, query, args...) } // SaveFlatKillmails saves flattened killmails, attackers, and items to ClickHouse using JSON format -func (c *Client) SaveFlatKillmails( +func (c *ClickhouseClient) SaveFlatKillmails( killmails []*types.FlatKillmail, attackers []types.FlatKillmailAttacker, items []types.FlatKillmailItem, @@ -78,7 +78,7 @@ func (c *Client) SaveFlatKillmails( } // insertKillmailsJSON inserts killmails using JSON format -func (c *Client) insertKillmailsJSON(ctx context.Context, killmails []*types.FlatKillmail) error { +func (c *ClickhouseClient) insertKillmailsJSON(ctx context.Context, killmails []*types.FlatKillmail) error { if len(killmails) == 0 { return nil } @@ -98,7 +98,7 @@ func (c *Client) insertKillmailsJSON(ctx context.Context, killmails []*types.Fla if len(jsonRows) > 0 { jsonData := strings.Join(jsonRows, "\n") query := fmt.Sprintf("INSERT INTO zkill.killmails FORMAT JSONEachRow\n%s", jsonData) - if err := c.conn.Exec(ctx, query); err != nil { + if err := c.Conn.Exec(ctx, query); err != nil { batchErrors = append(batchErrors, fmt.Errorf("failed to insert killmails batch: %w", err)) } } @@ -111,7 +111,7 @@ func (c *Client) insertKillmailsJSON(ctx context.Context, killmails []*types.Fla } // insertAttackersJSON inserts attackers using JSON format -func (c *Client) insertAttackersJSON(ctx context.Context, attackers []types.FlatKillmailAttacker) error { +func (c *ClickhouseClient) insertAttackersJSON(ctx context.Context, attackers []types.FlatKillmailAttacker) error { if len(attackers) == 0 { return nil } @@ -131,7 +131,7 @@ func (c *Client) insertAttackersJSON(ctx context.Context, attackers []types.Flat if len(jsonRows) > 0 { jsonData := strings.Join(jsonRows, "\n") query := fmt.Sprintf("INSERT INTO zkill.killmail_attackers FORMAT JSONEachRow\n%s", jsonData) - if err := c.conn.Exec(ctx, query); err != nil { + if err := c.Conn.Exec(ctx, query); err != nil { batchErrors = append(batchErrors, fmt.Errorf("failed to insert attackers batch: %w", err)) } } @@ -144,7 +144,7 @@ func (c *Client) insertAttackersJSON(ctx context.Context, attackers []types.Flat } // insertItemsJSON inserts items using JSON format -func (c *Client) insertItemsJSON(ctx context.Context, items []types.FlatKillmailItem) error { +func (c *ClickhouseClient) insertItemsJSON(ctx context.Context, items []types.FlatKillmailItem) error { if len(items) == 0 { return nil } @@ -164,7 +164,7 @@ func (c *Client) insertItemsJSON(ctx context.Context, items []types.FlatKillmail if len(jsonRows) > 0 { jsonData := strings.Join(jsonRows, "\n") query := fmt.Sprintf("INSERT INTO zkill.killmail_items FORMAT JSONEachRow\n%s", jsonData) - if err := c.conn.Exec(ctx, query); err != nil { + if err := c.Conn.Exec(ctx, query); err != nil { batchErrors = append(batchErrors, fmt.Errorf("failed to insert items batch: %w", err)) } }