Skip to content
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

Tutorial: Simple Connection #2

Merged
merged 14 commits into from
Jan 9, 2025
Merged

Tutorial: Simple Connection #2

merged 14 commits into from
Jan 9, 2025

Conversation

vector-of-bool
Copy link
Collaborator

This adds a very basic tutorial for connecting to a server, distinct from the more complex "communicating" how-to page.

This also adds several convenience APIs that make code much easier to read/write:

  • Overloads for amongoc_{then,let,just} for common parameter sets.
  • Test cases to ensure that the "overload" function macros are invocable in both C and C++ (this caught a few issues).
  • amongoc_detach_start for when you don't care about the operation state storage.

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM with tracing disabled. Not needed in this PR, but I request adding an example to show a CRUD operation (insert/find), which I expect most users would want to try.

fprintf(stderr, "Error while connecting to server: %s\n", msg);
free(msg);
} else {
printf("Successfully connected!\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest disabling the default enabled tracing. This example currently prints the full OPMSG sent and received:

send OP_MSG #0 (135 bytes)
  Section #1 body: {
    "hello": 1:i32,
    "$db": "admin",
    "client": {
      "driver": {
        "name": "amongoc",
        "version": "experimental-dev",
      },
      "os": { "type": "Linux" },
    },
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure how that got in. Oop.

@vector-of-bool vector-of-bool merged commit 63b04d2 into develop Jan 9, 2025
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.

2 participants