Skip to content

Update the Get Started tutorial for Go connector #4193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2024
Merged

Conversation

andreyaksenov
Copy link
Contributor

@andreyaksenov andreyaksenov commented May 15, 2024

Updated the Connecting from Go tutorial:
https://docs.d.tarantool.io/en/doc/connectors/how-to/getting_started_go/

This tutorial has the same steps and uses the same database as the Connecting to a database using net.box tutorial. The upcoming Python/C++ tutorials are going to have the same layout.

Note that Sphinx expands a tab (which is used as default indentation in Go) to 8 spaces. There are two ways to fix this:

  • Replace tabs with spaces
  • Customize CSS for our site

Not sure should we fix this.

@andreyaksenov andreyaksenov linked an issue May 15, 2024 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the connectors branch 3 times, most recently from 7772b32 to 3b54d84 Compare May 15, 2024 15:03
@andreyaksenov andreyaksenov changed the title Update Get Started tutorials for connectors Update the Get Started tutorial for Go connector May 16, 2024
@andreyaksenov andreyaksenov force-pushed the connectors branch 2 times, most recently from 0bb705a to b95c668 Compare May 16, 2024 08:55
@andreyaksenov andreyaksenov linked an issue May 16, 2024 that may be closed by this pull request
@andreyaksenov andreyaksenov marked this pull request as ready for review May 16, 2024 10:04
@andreyaksenov andreyaksenov force-pushed the connectors branch 3 times, most recently from 5bed468 to 2f36ece Compare May 16, 2024 14:16
Copy link
Contributor

@p7nov p7nov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear and complete tutorial, like it 👍
Some minor comments/ideas from my side.

)

func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you can add a comment // Connect to the database to make this source file more readable even without the doc page.

if err != nil {
fmt.Println("Got an error:", err)
}
fmt.Println("Tuple selected the primary key value:", data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the key value?
Same for secondary key (line 77)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg, thanks!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pre-requisites
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The tutorial shows how to use the 2.x version of the `go-tarantool <https://github.com/tarantool/go-tarantool>`__ library to create a Go application that connects to a remote Tarantool instance, performs CRUD operations, and executes a stored procedure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the direct order of words:

... how to use the go-tarantool 2.x library

because this page is firstly about go-tarantool, and secondarily - about 2.x version.
Besides, if I get it right, we're not gonna provide content on earlier go-tarantool versions, so no sense in highlighting the version in the first place.

This section describes the :ref:`configuration <configuration_file>` of a sample database that allows remote connections:

.. literalinclude:: /code_snippets/snippets/connectors/instances.enabled/sample_db/config.yaml
:language: yaml
:dedent:

- The configuration contains one instance that listens incoming requests on the ``127.0.0.1:3301`` address.
- The configuration contains one instance that listens for incoming requests on the ``127.0.0.1:3301`` address.
- ``sampleuser`` has :ref:`privileges <authentication-owners_privileges>` to select and modify data in the ``bands`` space and execute the ``get_bands_older_than`` stored function. This user can be used to connect to the instance remotely.
- ``myapp.lua`` defines how data is stored in a database and includes a stored function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ``myapp.lua`` defines how data is stored in a database and includes a stored function.
- ``myapp.lua`` defines the data model and a stored function.


#. In order to connect to Tarantool as an administrator, reset the password
for the ``admin`` user:
Before creating and starting a client Go application, you need to run the :ref:`sample_db <getting_started_net_box_sample_db>` application using ``tt start``:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some link to tutorial on starting the app?
I expect that some readers may be Go developers that are complete newcomers to Tarantool and literally know nothing about it and tt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a link to 'tt start'

Finally, it would be nice to select all the tuples in a space. But there is no
one-liner for this in Go; you would need a script like
:ref:`this one <cookbook-select-all-go>`.
Using data operations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Performing?
Or just Manipulating data
Using operations sounds a bit strange to me

To delete all tuples in a space (or to delete an entire space), use ``Call``.
We'll focus on this function in more detail in the
:ref:`next <getting_started-go-stored-procs>` section.
``NewUpdateRequest()`` can be used to update a tuple identified by the primary key as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``NewUpdateRequest()`` can be used to update a tuple identified by the primary key as follows:
``NewUpdateRequest()`` updates a tuple identified by the primary key as follows:

Here and in some places below.
Less words, more direct expression. Anyway, up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, NewUpdateRequest() doesn't update a tuple - it creates an object that is used by the connection to update a tuple. So, I'd keep it as is.

:end-at: Connection is closed
:dedent:

.. NOTE::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this note in the beginning of Developing subsection so that some readers can read the code instead of the procedure doc if they like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, I place the links to full samples at the beginning and at the end of tutorials. Note that the first link already added right after the topic's title.


.. _getting_started-go-comparison:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Feature comparison
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a clearer heading here. Readers don't know about other connectors Feature comparison is unclear in this context: "Whose features? Comparison with what?"

@andreyaksenov andreyaksenov force-pushed the connectors branch 2 times, most recently from e23c5f0 to d084a84 Compare May 17, 2024 08:00
@andreyaksenov andreyaksenov merged commit 24a959d into latest May 17, 2024
1 check failed
@andreyaksenov andreyaksenov deleted the connectors branch May 17, 2024 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feedback: Connecting from Go | Tarantool [Config] Update the Get Started tutorial for Go connector
3 participants