go-tarantool
go-tarantool copied to clipboard
Add ability to connect through admin (control) socket
At the moment connector allow to connect through tcp and unix socket, but sometimes it's can be useful to connect through “admin port”.
Expect behavior is like in tarantoolctl.
Step to reproduce:
- Create
init.lua
local console = require('console')
box.cfg{
listen = 'unix/:./tnt.sock'
}
box.schema.user.grant('guest','super')
console.listen('unix/:./tnt.control')
- Start tarantool
tarantool init.lua
- Try to connect via tarantoolctl through unix socket (it should works)
tarantoolctl connect unix/:./tnt.sock
- Try to connect via tarantoolctl through admin socket (it should works too)
tarantoolctl connect unix/:./tnt.control
- Now create main.go and try the same connections from go
// main.go
package main
import (
"fmt"
"github.com/tarantool/go-tarantool"
"log"
)
func main() {
opts := tarantool.Opts{}
connUnixSocket, err := tarantool.Connect("unix/:./tnt.sock", opts)
if err != nil {
log.Fatalf("Unix socket not connected: %s", err)
}
fmt.Printf("Version from unix socket is %s", connUnixSocket.Greeting.Version)
connControlSocket, err := tarantool.Connect("unix/:./tnt.control", opts)
if err != nil {
log.Fatalf("Control socket not connected: %s\n", err)
}
fmt.Printf("Version from control socket is %s", connControlSocket.Greeting.Version)
}
- Try to execute it
go run main.go
Actual result:
Version from unix socket is Tarantool 2.10.0 (Binary) bee3cc79-e645-4cea-ad1b-b4aed844f4ba
2022/07/08 12:13:29 Control socket not connected: Wrong reponse header
exit status 1
Expected result:
Version from unix socket is Tarantool 2.10.0 (Binary) bee3cc79-e645-4cea-ad1b-b4aed844f4ba
Version from control socket is Tarantool 2.10.0 (Binary) bee3cc79-e645-4cea-ad1b-b4aed844f4ba
Is there an example implementation in another connector?
Is there an example implementation in another connector?
At least in tarantoolctl
https://github.com/tarantool/tarantool/blob/master/extra/dist/tarantoolctl.in
New CLI "TT" is written in go and works with it https://github.com/tarantool/tt/tree/master/cli/connector
@kluevandrew https://github.com/tarantool/tt/blob/f9224f9/cli/connector/connector.go#L91-L92
wow, there is really writing and reading in plain text https://github.com/tarantool/tt/blob/f9224f9aae657ff4cc0df6f1f5011c0244016fd2/cli/connector/eval_plain_text.go#L129
Is there an example implementation in another connector?
@Totktonada you can check https://github.com/igorcoding/asynctnt/blob/master/tests/test_connect.py#L83
@NeraverinTarantool It is usual for connectors to have a test helper to work with a console to don't prepare data for testing with tested functions. IOW, to don't test the binary protocol implementation using this implementation itself.
I meant implementation in a connector's public API, not internally for testing purposes.
Any news on it?
We have no plans to implement and support in. But nevertheless it may be done by community