tarantool / tarantool/doc

Document `from_fd` net.box module function

Open
#3,619 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.0 feature netbox reference
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

Product: Tarantool
Since: 3.0
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/
SME: @ locker

Details

The function takes a file descriptor number (fd) as its first argument
and a table of connection options as its second, optional argument. It
creates and returns a new connection object.

The fd should point to a socket and be switched to the non-blocking
mode, but this isn't enforced. If the fd is invalid, the connection may
not work as expected.

The functions take the same options as connect.

The function takes the ownership of the fd, i.e. the fd must not be used
or closed after this function successfully returns.

Example:

The code below connects to a Tarantool instance at port 3301 using
the socket module, then wraps the socket fd in a net.box
connection object.

local net = require('net.box')
local socket = require('socket')

-- Connect a socket then wrap it in a net.box connection object.
local s = socket.tcp_connect('localhost', 3301)
assert(s ~= nil)
local conn = net.from_fd(s:fd(), {fetch_schema = false})
s:detach()

conn:call('box.schema.user.info')
conn:close()

Requested by @locker in https://github.com/tarantool/tarantool/commit/ae441c995e25c965a969ac1381487fc23c1f0643.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Update the net.box reference page linked as the root document, locating the module-function section and the existing connect documentation. Document from_fd's arguments, non-blocking fd requirement, option handling, ownership, and the provided socket example; done when the function is covered consistently in the reference page.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.