tldb支持在后台进行数据库系列操作以及集群状态,集群数据,节点数据的查询与监测
tldb管理后台账户以访问控制权限分: 管理员与限制管理员管理权限区别:
- 管理员: 可以创建其他管理员以及所有数据操作
- 数据管理员:可以进行所有数据操作
在线测试后台
用户名:admin
密码:123456
测试数据库客户端
客户端访问地址: db.tlnet.top:7001
客户端TLS访问地址: db.tlnet.top:7002
用户名:mycli
密码:123
go 客户端为例:
package client
import (
"testing"
"github.com/donnie4w/simplelog/logging"
"github.com/donnie4w/tlcli-go/tlcli"
"github.com/donnie4w/tlorm-go/orm"
)
func Test_client(t *testing.T) {
if client, err := tlcli.NewConnect(false, "db.tlnet.top:7001", "mycli=123"); err == nil {
//create table
client.CreateTable("usertest", []string{"name", "age", "type"}, []string{"name", "type"})
//insert data
datamap := map[string][]byte{"name": []byte("tom"), "age": []byte("1"), "type": []byte("1")}
seq, _ := client.Insert("usertest", datamap)
logging.Debug("id:", seq) //return id
if data, err := client.SelectById("usertest", seq); err == nil {
for k, v := range data.TBean {
logging.Debug(k, "==", string(v))
}
}
}
}
// 客户端 TLS 连接,并测试数据操作
func Test_clientTls(t *testing.T) {
if client, err := tlcli.NewConnect(true, "db.tlnet.top:7002", "mycli=123"); err == nil {
//create table
client.CreateTable("usertest", []string{"name", "age", "type"}, []string{"name", "type"})
//insert data
datamap := map[string][]byte{"name": []byte("jerry"), "age": []byte("2"), "type": []byte("2")}
seq, _ := client.Insert("usertest", datamap)
logging.Debug("id:", seq) //return id
if data, err := client.SelectById("usertest", seq); err == nil {
for k, v := range data.TBean {
logging.Debug(k, "==", string(v))
}
}
}
}
type UserOrm struct {
Id int64
Name string
Age int
Level byte
Balance float64
}
//orm 测试
func Test_orm(t *testing.T) {
orm.RegisterDefaultResource(false, "db.tlnet.top:7001", "mycli=123")
//create table
orm.Create[UserOrm]()
//insert data
seq, _ := orm.Insert(&UserOrm{Name: "tom", Age: 20, Level: 1, Balance: 99.2})
//select
u, _ := orm.SelectById[UserOrm](seq)
logging.Debug(u)
}
测试数据库MQ
MQ访问地址: ws://db.tlnet.top:5001
MQ TLS访问地址: wss://db.tlnet.top:5002
用户名:mymq
密码:123
go mq 客户端为例:
package mq
import (
"testing"
"github.com/donnie4w/simplelog/logging"
"github.com/donnie4w/tlmq-go/cli"
. "github.com/donnie4w/tlmq-go/stub"
)
func TestMq(t *testing.T) {
sc := &cli.SimpleClient{Url: "ws://db.tlnet.top:5001", Auth: "mymq=123"}
sc.PubJsonHandler = func(jmb *cli.JMqBean) { logging.Debug("PubJson >> ", jmb) }
sc.Connect()
//Subscriber "userinfotopic"
sc.Sub("userinfotopic")
//publish "userinfotopic"
sc.PubJson("userinfotopic", "this is first pub json msg")
}
func TestMqTls(t *testing.T) {
sc := &cli.SimpleClient{Url: "wss://db.tlnet.top:5002", Auth: "mymq=123"}
sc.PubByteHandler = func(mb *MqBean) { logging.Debug("PubByte >> ", mb) }
sc.Connect()
//Subscriber "imtopic"
sc.Sub("imtopic")
//publish "imtopic"
sc.PubByte("imtopic", []byte("this is first pub bytes msg"))
}