box

package
v2.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2025 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Example
dialer := tarantool.NetDialer{
	Address:  "127.0.0.1:3013",
	User:     "test",
	Password: "test",
}
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
client, err := tarantool.Connect(ctx, dialer, tarantool.Opts{})
cancel()
if err != nil {
	log.Fatalf("Failed to connect: %s", err)
}

// You can use Info Request type.

fut := client.Do(box.NewInfoRequest())

resp := &box.InfoResponse{}

err = fut.GetTyped(resp)
if err != nil {
	log.Fatalf("Failed get box info: %s", err)
}

// Or use simple Box implementation.

b := box.New(client)

info, err := b.Info()
if err != nil {
	log.Fatalf("Failed get box info: %s", err)
}

if info.UUID != resp.Info.UUID {
	log.Fatalf("Box info uuids are not equal")
}

fmt.Printf("Box info uuids are equal")
fmt.Printf("Current box info: %+v\n", resp.Info)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box struct {
	// contains filtered or unexported fields
}

Box is a helper that wraps box.* requests. It holds a connection to the Tarantool instance via the Doer interface.

func New

func New(conn tarantool.Doer) *Box

New returns a new instance of the box structure, which implements the Box interface.

func (*Box) Info

func (b *Box) Info() (Info, error)

Info retrieves the current information of the Tarantool instance. It calls the "box.info" function and parses the result into the Info structure.

type Downstream added in v2.3.0

type Downstream struct {
	// Status is replication status of the connection with the instance.
	Status string `msgpack:"status"`
	// Idle is the time (in seconds) since the last event was received.
	Idle float64 `msgpack:"idle"`
	// VClock contains the vector clock, which is a table of ‘id, lsn’ pairs.
	VClock map[int]uint64 `msgpack:"vclock"`
	// Lag is the time difference between the local time of instance n,
	// recorded when the event was received, and the local time at another master
	// recorded when the event was written to the write-ahead log on that master.
	Lag float64 `msgpack:"lag"`
	// Message contains an error message in case of a degraded state; otherwise, it is nil.
	Message string `msgpack:"message,omitempty"`
	// SystemMessage contains an error message in case of a degraded state; otherwise, it is nil.
	SystemMessage string `msgpack:"system_message,omitempty"`
}

Downstream information.

type Info

type Info struct {
	// The Version of the Tarantool instance.
	Version string `msgpack:"version"`
	// The node ID (nullable).
	ID *int `msgpack:"id"`
	// Read-only (RO) status of the instance.
	RO bool `msgpack:"ro"`
	// UUID - Unique identifier of the instance.
	UUID string `msgpack:"uuid"`
	// Process ID of the instance.
	PID int `msgpack:"pid"`
	// Status - Current status of the instance (e.g., running, unconfigured).
	Status string `msgpack:"status"`
	// LSN - Log sequence number of the instance.
	LSN uint64 `msgpack:"lsn"`
	// Replication - replication status.
	Replication map[int]Replication `msgpack:"replication,omitempty"`
}

Info represents detailed information about the Tarantool instance. It includes version, node ID, read-only status, process ID, cluster information, and more.

type InfoRequest

type InfoRequest struct {
	// contains filtered or unexported fields
}

InfoRequest represents a request to retrieve information about the Tarantool instance. It implements the tarantool.Request interface.

func NewInfoRequest

func NewInfoRequest() InfoRequest

NewInfoRequest returns a new empty info request.

func (InfoRequest) Async

func (req InfoRequest) Async() bool

Async returns request expects a response.

func (InfoRequest) Body

func (i InfoRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error

Body method is used to serialize the request's body. It is part of the tarantool.Request interface implementation.

func (InfoRequest) Ctx

func (req InfoRequest) Ctx() context.Context

Ctx returns a context of request.

func (InfoRequest) Response

func (req InfoRequest) Response(header tarantool.Header,
	body io.Reader) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (InfoRequest) Type

func (req InfoRequest) Type() iproto.Type

Type returns IPROTO type for request.

type InfoResponse

type InfoResponse struct {
	Info Info
}

InfoResponse represents the response structure that holds the information of the Tarantool instance. It contains a single field: Info, which holds the instance details (version, UUID, PID, etc.).

func (*InfoResponse) DecodeMsgpack

func (ir *InfoResponse) DecodeMsgpack(d *msgpack.Decoder) error

type Replication added in v2.3.0

type Replication struct {
	// ID is a short numeric identifier of instance n within the replica set.
	ID int `msgpack:"id"`
	// UUID - Unique identifier of the instance.
	UUID string `msgpack:"uuid"`
	// LSN - Log sequence number of the instance.
	LSN uint64 `msgpack:"lsn"`
	// Upstream - information about upstream.
	Upstream Upstream `msgpack:"upstream,omitempty"`
	// Downstream - information about downstream.
	Downstream Downstream `msgpack:"downstream,omitempty"`
}

Replication section of box.info() is a table with statistics for all instances in the replica set that the current instance belongs to.

type Upstream added in v2.3.0

type Upstream struct {
	// Status is replication status of the connection with the instance.
	Status string `msgpack:"status"`
	// Idle is the time (in seconds) since the last event was received.
	Idle float64 `msgpack:"idle"`
	// Peer contains instance n’s URI.
	Peer string `msgpack:"peer"`
	// Lag is the time difference between the local time of instance n,
	// recorded when the event was received, and the local time at another master
	// recorded when the event was written to the write-ahead log on that master.
	Lag float64 `msgpack:"lag"`
	// Message contains an error message in case of a degraded state; otherwise, it is nil.
	Message string `msgpack:"message,omitempty"`
	// SystemMessage contains an error message in case of a degraded state; otherwise, it is nil.
	SystemMessage string `msgpack:"system_message,omitempty"`
}

Upstream information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL