forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: add the ability to connect via socket fd
This patch introduces `FdDialer`, which connects to Tarantool using an existing socket file descriptor. `FdDialer` is not authenticated when creating a connection. Part of #321
- Loading branch information
1 parent
3dccc1c
commit 4e06766
Showing
6 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
work_dir* | ||
.rocks | ||
bench* | ||
testdata/sidecar/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/tarantool/go-tarantool/v2" | ||
) | ||
|
||
func main() { | ||
fd, err := strconv.Atoi(os.Getenv("SOCKET_FD")) | ||
if err != nil { | ||
panic(err) | ||
} | ||
dialer := tarantool.FdDialer{ | ||
Fd: uintptr(fd), | ||
} | ||
conn, err := tarantool.Connect(context.Background(), dialer, tarantool.Opts{}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if _, err := conn.Do(tarantool.NewPingRequest()).Get(); err != nil { | ||
panic(err) | ||
} | ||
// Insert new tuple. | ||
if _, err := conn.Do(tarantool.NewInsertRequest("test"). | ||
Tuple([]interface{}{239})).Get(); err != nil { | ||
panic(err) | ||
} | ||
// Delete inserted tuple. | ||
if _, err := conn.Do(tarantool.NewDeleteRequest("test"). | ||
Index("primary"). | ||
Key([]interface{}{239})).Get(); err != nil { | ||
panic(err) | ||
} | ||
} |