Documentation
¶
Overview ¶
Package decimal with support of Tarantool's decimal data type.
Decimal data type supported in Tarantool since 2.2.
Since: 1.7.0
See also:
Tarantool MessagePack extensions: https://www.tarantool.io/en/doc/latest/dev_guide/internals/msgpack_extensions/#the-decimal-type
Tarantool data model: https://www.tarantool.io/en/doc/latest/book/box/data_model/
Tarantool issue for support decimal type: https://github.com/tarantool/tarantool/issues/692
Tarantool module decimal: https://www.tarantool.io/en/doc/latest/reference/reference_lua/decimal/
Example ¶
To enable support of decimal in msgpack with https://github.com/shopspring/decimal, import tarantool/decimal submodule.
server := "127.0.0.1:3013"
dialer := tarantool.NetDialer{
Address: server,
User: "test",
Password: "test",
}
opts := tarantool.Opts{
Timeout: 5 * time.Second,
}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
client, err := tarantool.Connect(ctx, dialer, opts)
cancel()
if err != nil {
log.Fatalf("Failed to connect: %s", err.Error())
}
spaceNo := uint32(524)
number, err := MakeDecimalFromString("-22.804")
if err != nil {
log.Fatalf("Failed to prepare test decimal: %s", err)
}
data, err := client.Do(tarantool.NewReplaceRequest(spaceNo).
Tuple([]interface{}{number}),
).Get()
if err != nil {
log.Fatalf("Decimal replace failed: %s", err)
}
log.Println("Decimal tuple replace")
log.Println("Error", err)
log.Println("Data", data)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
func MakeDecimal ¶
MakeDecimal creates a new Decimal from a decimal.Decimal.
func MakeDecimalFromString ¶
MakeDecimalFromString creates a new Decimal from a string.