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" opts := tarantool.Opts{ Timeout: 5 * time.Second, Reconnect: 1 * time.Second, MaxReconnects: 3, User: "test", Pass: "test", } client, err := tarantool.Connect(server, opts) if err != nil { log.Fatalf("Failed to connect: %s", err.Error()) } spaceNo := uint32(524) number, err := NewDecimalFromString("-22.804") if err != nil { log.Fatalf("Failed to prepare test decimal: %s", err) } resp, err := client.Replace(spaceNo, []interface{}{number}) if err != nil { log.Fatalf("Decimal replace failed: %s", err) } if resp == nil { log.Fatalf("Response is nil after Replace") } log.Println("Decimal tuple replace") log.Println("Error", err) log.Println("Code", resp.Code) log.Println("Data", resp.Data)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decimal ¶
func NewDecimal ¶
NewDecimal creates a new Decimal from a decimal.Decimal.
func NewDecimalFromString ¶
NewDecimalFromString creates a new Decimal from a string.
func (*Decimal) MarshalMsgpack ¶
MarshalMsgpack serializes the Decimal into a MessagePack representation.
func (*Decimal) UnmarshalMsgpack ¶
UnmarshalMsgpack deserializes a Decimal value from a MessagePack representation.