zikwall / clickhouse-buffer Goto Github PK
View Code? Open in Web Editor NEWNative Go, fast and easy-to-use writer for asynchronous streaming batches to ClickHouse. Used in production services.
License: Apache License 2.0
Native Go, fast and easy-to-use writer for asynchronous streaming batches to ClickHouse. Used in production services.
License: Apache License 2.0
Based on the results of performance tests (https://github.com/ClickHouse/ch-bench#benchmarks ) it can be seen that the low-level API library is much faster than the clickhouse-go (https://github.com/ClickHouse/clickhouse-go) library in terms of data processing speed.
It would be nice to integrate the ability to use a lower-level library (https://github.com/ClickHouse/ch-go) with connection pool support.
redis buffer value encode err: gob: type not registered for interface: types.DateTime
there: https://github.com/zikwall/clickhouse-buffer/blob/master/write.go#L227-L243 (w.clickhouseCh = nil)
and there: https://github.com/zikwall/clickhouse-buffer/blob/master/write.go#L187-L201 (w.bufferCh = nil)
Why? you can, for example, write metrics in Prometheus or organize your own custom processing.
Writer callbacks
// call after write to tmp buffer
func onWrite(view cx.View) {}
// call after write batch to Clickhouse
func onWriteClickhouse(view cx.View, count uint64) {}
// call if write to clickhouse return error
// if this function has called, then repeated attempts are not enabled
func onWriteClickhouseError(err error, batch *cx.Batch) {}
Retry callbacks
// call after batch push to retry queue
func onRetryPush() {}
// call after rerty successfully handle
func onRetryComplete(view cx.View, countAttempt uint8) {}
// call if retry batch fails
func onRetryFail(err error, batch *retry.Retry)
examples:
// note: there is a pseudocode
func onWriteClickhouse(view cx.View, count uint64) {
prometheus.WithLabelValues("clickhouse", view.Table).Add(count)
}
func onWriteClickhouseError(err error, batch *cx.Batch) {
// code
prometheus.WithLabelValues("clickhouse", batch.View().Table, getErrorHumanableCode(err)).Inc()
// save batch to athoner storange, for example file
_ = failservice.Encode(batch).Write(ctx)
// other code
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.