MCPcopy
hub / github.com/flike/kingshard

github.com/flike/kingshard @1.6 sqlite

repository ↗ · DeepWiki ↗ · release 1.6 ↗
901 symbols 2,616 edges 66 files 186 documented · 21%
README

kingshard 中文主页

Author Build Status Foundation

Overview

kingshard is a high-performance proxy for MySQL powered by Go. Just like other mysql proxies, you can use it to split the read/write sqls. Now it supports basic SQL statements (select, insert, update, replace, delete). The most important feature is the sharding function. Kingshard aims to simplify the sharding solution of MySQL. The Performance of kingshard is about 80% compared to connecting to MySQL directly.

Feature

1. Basic Function

  • Splits reads and writes
  • Client's ip ACL control.
  • Transaction in single node.
  • Support limitting the max count of connections to MySQL database.
  • Support setting the backend database online or offline dynamically.
  • Supports prepared statement: COM_STMT_PREPARE, COM_STMT_EXECUTE, etc.
  • Support multi slaves, and loading banlance between slaves.
  • Support reading master database forcely.
  • Support last_insert_id().
  • Support MySQL backends HA.
  • Support set the charset of proxy.
  • Support SQL blacklist.
  • Support dynamically changing the config value of kingshard.

2. Sharding Function

  • Support hash,range and date sharding across multiple nodes.
  • Support sending sql to the specified node.
  • Support most commonly used functions, such as max, min, count, sum, and also support join, limit, order by,group by.

Install

  1. Install Go
  2. git clone https://github.com/flike/kingshard.git src/github.com/flike/kingshard
  3. cd src/github.com/flike/kingshard
  4. source ./dev.sh
  5. make
  6. set the config file (etc/ks.yaml)
  7. run kingshard (./bin/kingshard -config=etc/ks.yaml)

Details of kingshard

1.How to use kingshard building a MySQL cluster

License

kingshard is under the Apache 2.0 license. See the LICENSE directory for details.

Extension points exported contracts — how you extend this code

Handler (Interface)
Handler writes logs to somewhere [6 implementers]
core/golog/handler.go
SQLNode (Interface)
SQLNode defines the interface for all nodes generated by the parser. [44 implementers]
sqlparser/ast.go
Shard (Interface)
(no doc) [6 implementers]
proxy/router/shard.go
BinWriter (Interface)
BinWriter interface is used for encoding values. Types like bytes.Buffer conform to this interface. We expect the writer
sqltypes/sqltypes.go
Statement (Interface)
Statement represents a statement. [17 implementers]
sqlparser/ast.go
RangeShard (Interface)
*一个范围的分片,例如[start,end)*/ [1 implementers]
proxy/router/shard.go
InnerValue (Interface)
InnerValue defines methods that need to be supported by all non-null value types.
sqltypes/sqltypes.go
Expr (Interface)
Expr represents an expression. [15 implementers]
sqlparser/ast.go

Core symbols most depended-on inside this repo

Error
called by 127
sqlparser/sql.go
Fprintf
called by 112
sqlparser/tracked_buffer.go
Close
called by 105
core/golog/handler.go
String
called by 60
proxy/router/shard.go
GetFingerprint
called by 60
mysql/sql_fingerprint.go
Execute
called by 59
backend/stmt.go
String
called by 53
sqltypes/sqltypes.go
Prepare
called by 21
backend/stmt.go

Shape

Method 540
Function 227
Struct 94
TypeAlias 22
Interface 18

Languages

Go100%

Modules by API surface

sqlparser/ast.go216 symbols
sqltypes/sqltypes.go40 symbols
backend/backend_conn.go38 symbols
proxy/server/server.go37 symbols
proxy/router/shard.go28 symbols
proxy/router/planbuilder.go28 symbols
proxy/server/conn_admin.go27 symbols
proxy/router/router.go26 symbols
core/golog/log.go25 symbols
proxy/server/conn_select.go22 symbols
backend/db.go22 symbols
mysql/resultset.go21 symbols

For agents

$ claude mcp add kingshard \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact