Giter Club home page Giter Club logo

obkv-table-client-go's Introduction

obkv-table-client-go

OBKV Table Client is go Library that can be used to access table data from OceanBase storage layer. Its access method is different from JDBC, it skips the SQL parsing layer, so it has significant performance advantage.

Quick Start

Create table in the OceanBase database:

CREATE TABLE IF NOT EXISTS `test` (
    `c1` bigint(20) NOT NULL,
    `c2` bigint(20) NOT NULL,
    PRIMARY KEY (`c1`)
) PARTITION BY KEY(`c1`) PARTITIONS 10;

The code demo:

    const (
		configUrl    = "ob-configserver-url"
		fullUserName = "user@tenant#cluster"
		passWord     = ""
		sysUserName  = "root"
		sysPassWord  = ""
		tableName    = "test"
	)

	cfg := config.NewDefaultClientConfig()
	cli, err := client.NewClient(configUrl, fullUserName, passWord, sysUserName, sysPassWord, cfg)
	if err != nil {
		panic(err)
	}

	// insert
	rowKey := []*table.Column{table.NewColumn("c1", int64(1))}
	insertColumns := []*table.Column{table.NewColumn("c2", int64(2))}
	affectRows, err := cli.Insert(
		context.TODO(),
		tableName,
		rowKey,
		insertColumns,
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(affectRows)

	// get
	selectColumns := []string{"c1", "c2"}
	result, err := cli.Get(
		context.TODO(),
		tableName,
		rowKey,
		selectColumns,
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(result.Value("c1"))
	fmt.Println(result.Value("c2"))

NOTE:

  1. configUrl is generated by ConfigServer.
  2. fullUserName: the user for accessing obkv, which format is user_name@tenant_name#cluster_name
  3. passWord: the password of user in fullUserName.
  4. sysUserName: root or proxy, which have privileges to access routing system view
  5. sysPassWord: the password of sys user in sysUserName.

Documentation

Licencing

obkv-table-client-go is under MulanPSL - 2.0 licence. You can freely copy and use the source code. When you modify or distribute the source code, please obey the MulanPSL - 2.0 licence.

Contributing

Contributions are warmly welcomed and greatly appreciated. Here are a few ways you can contribute:

Support

In case you have any problems when using OceanBase Database, welcome reach out for help:

obkv-table-client-go's People

Contributors

dependabot[bot] avatar eter365 avatar foronedream avatar groundwu avatar iheii avatar lyxiong0 avatar namewxt1220 avatar shenyunlong avatar smallsongz avatar weixinchan avatar xiaoaiaxss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obkv-table-client-go's Issues

[Enhancement]: Print the peer address when execute failed

Description

When execute failed or timeout, the client only print the trace id and some error message, but lack of the peer address, which it's difficult for trouble shooting, especially when your cluster size is relatively large.

the printed log is same as the following currently:

obtable execute: wait transport packet, trace: Y1FFF12167458D-00000000000000BC: context deadline exceeded, stack:goroutine 392234 [running]:

In a word, expect to print the peer address of the connection when request execute failed.

[Bug]: [v0.1.0] [example/single_operation/get.go]The type of column c2 in the SQL statement does not match the type in the insert operation

Describe the bug

The type of column c2 in the SQL statement does not match the type in the insert operation

Environment

  • OS Version and CPU Arch(uname -a):
    any
  • Component Version:

v0.1.0
Fast Reproduce Steps(Required)

Steps to reproduce the behavior:

  • execute the sql of CREATE TABLE
  • go run example/single_operation/get.go

Expected behavior

pass

Actual Behavior

panic: execute insert, tableName:test, rowKey:[column{name:c1, value:1}], mutateColumns:[column{name:c2, value:2}]: errCode:-4001, errCodeName:ObObjTypeError, errMsg:Column type not match., server:xxxxxx, trace:xxxx, tableName:test

Additional context

[Enhancement]: timeout period time for Query

Enhancement
Now, each query request uses the operation timeout. The total time of the Query is unlimited.
It is better to implement a Query timeout to restrict the execution time.

[Feature]: 泛化客户端 同时支持sql

Describe your use case

在写数据的时候,使用sql + 事务来写数据, 读数据的时候,采用table store来读数据

Describe the solution you'd like

目前使用oceanbase的话,需要两个独立的client,需要应用自己整合两个client在一起才可以.
能否提供generic client,能够同时使用这两者呢.

Describe alternatives you've considered

No response

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.