
Security News
Open VSX Begins Implementing Pre-Publish Security Checks After Repeated Supply Chain Incidents
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.
trpc.group/trpc-go/trpc-database/clickhouse
Advanced tools
This project depends on clickhouse-go's v2 version, which is compatible with [v1 version dsn](https://github.com/ClickHouse/clickhouse-go /tree/v1#dsn), in order to prevent omissions, it is recommended to use v2 version of dsn.
Please note that the v2 version has a strong limitation on the type. The type of the written data must completely correspond to the type defined in the table. For example, if the table defines UInt8, the written data type must be uint8, and other digital types will also report errors.
In addition, 3 connection parameter configurations
max_idle, max_open, max_lifetimehave been added to dsn, which is convenient for users to customize connection configuration.
client: # Backend configuration for client calls.
service: # Configuration for the backend.
- name: trpc.clickhouse.ip.v1
target: clickhouse://ip:port?username=*&password=*&database=* # clickhouse standard uri: tcp://host1[:port1][?options] , see https://github.com/ClickHouse/clickhouse-go/tree/v1#dsn
timeout: 800 # The maximum processing time of the current request.
- name: trpc.clickhouse.name.v1
target: clickhouse+polaris://polaris_name?username=*&password=*&database=* # clickhouse+polaris indicates that the host in the clickhouse uri will perform Polaris analysis.
timeout: 800 # The maximum processing time of the current request.
- name: trpc.clickhouse.ip.v2
target: clickhouse://username:password@ip:port/database?dial_timeout=200ms # clickhouse standard uri: clickhouse://username:password@host1[:port1]/database[?options], see https://github.com/ClickHouse/clickhouse-go#dsn
timeout: 800 # The maximum processing time of the current request.
- name: trpc.clickhouse.name.v2
target: clickhouse+polaris://username:password@polaris_name/database?max_idle=10&max_open=100&max_lifetime=3m # clickhouse+polaris indicates that the host in the clickhouse uri will perform Polaris analysis.
timeout: 800 # The maximum processing time of the current request.
package main
import (
"fmt"
"time"
"context"
"trpc.group/trpc-go/trpc-database/clickhouse"
)
type TableRow struct {
Country string `db:"country_code"`
Os uint8 `db:"os_id"`
Browser uint8 `db:"browser_id"`
Categories []int16 `db:"categories"`
ActionDay time.Time `db:"action_day"`
ActionTime time.Time `db:"action_time"`
}
func (s *server) SayHello(ctx context.Context, req *pb.ReqBody, rsp *pb.RspBody) (err error) {
proxy := clickhouse.NewClientProxy("trpc.clickhouse.xxx.xxx") // The service name is customized
// and is mainly used for monitoring reporting and addressing configuration items。
var results []*TableRow
err := proxy.QueryToStructs(ctx, &results, "SELECT country_code, os_id, browser_id, categories, action_day, action_time FROM example LIMIT 5")
if err != nil {
return err
}
for _, val := range results {
fmt.Printf("%+v", val)
}
// Business logic
// ......
return
}
clickhouse client configuration, the context context will be terminated after the timeout expires, causing the query request to stop and an error is reported, and the timeout configuration can be adjusted according to the situation.FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.

Research
/Security News
Threat actors compromised four oorzc Open VSX extensions with more than 22,000 downloads, pushing malicious versions that install a staged loader, evade Russian-locale systems, pull C2 from Solana memos, and steal macOS credentials and wallets.

Security News
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.