Skip to content

Commit

Permalink
api: remove unused _uint64 options accessors for contexts and sockets
Browse files Browse the repository at this point in the history
Also, clarification and add socket option docs for MAXRECVSZ, RECONNMINT, RECONNMAXT
  • Loading branch information
gdamore committed Jan 2, 2025
1 parent 61c886e commit c0b1557
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 34 deletions.
4 changes: 1 addition & 3 deletions docs/ref/api/ctx.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,11 @@ int nng_ctx_get_bool(nng_ctx ctx, const char *opt, bool *valp);
int nng_ctx_get_int(nng_ctx ctx, const char *opt, int *valp);
int nng_ctx_get_ms(nng_ctx ctx, const char *opt, nng_duration *valp);
int nng_ctx_get_size(nng_ctx ctx, const char *opt, size_t *valp);
int nng_ctx_get_uint64(nng_ctx ctx, const char *opt, uint64_t *valp);
int nng_ctx_set_bool(nng_ctx ctx, const char *opt, int val);
int nng_ctx_set_int(nng_ctx ctx, const char *opt, int val);
int nng_ctx_set_ms(nng_ctx ctx, const char *opt, nng_duration val);
int nng_ctx_set_size(nng_ctx ctx, const char *opt, size_t val);
int nng_ctx_set_uint64(nng_ctx ctx, const char *opt, uint64_t val);
```

Some protocols support certain options that affect the behavior of a specific context.
Expand All @@ -189,7 +187,7 @@ The `nng_ctx_get_` functions retrieve the value from _ctx_, and store it in the
The `nng_ctx_set_` functions change the value for the _ctx_, taking it from _val_.

These functions access an option as a specific type. The protocol documentation will have details about which options
are available for contexts, whether they can be read or written, and which type they may be accessed using.
are available for contexts, whether they can be read or written, and the appropriate type to use.

## Examples

Expand Down
13 changes: 10 additions & 3 deletions docs/ref/api/sock.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,11 @@ int nng_socket_get_bool(nng_socket s, const char *opt, bool *valp);
int nng_socket_get_int(nng_socket s, const char *opt, int *valp);
int nng_socket_get_ms(nng_socket s, const char *opt, nng_duration *valp);
int nng_socket_get_size(nng_socket s, const char *opt, size_t *valp);
int nng_socket_get_uint64(nng_socket s, const char *opt, uint64_t *valp);

int nng_socket_set_bool(nng_socket s, const char *opt, int val);
int nng_socket_set_int(nng_socket s, const char *opt, int val);
int nng_socket_set_ms(nng_socket s, const char *opt, nng_duration val);
int nng_socket_set_size(nng_socket s, const char *opt, size_t val);
int nng_socket_set_uint64(nng_socket s, const char *opt, uint64_t val);
```
Protocols usually have protocol specific behaviors that can be adjusted via options.
Expand All @@ -306,12 +304,21 @@ The following options are available for many protocols, and always use the same
| Option | Type | Description |
| --------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `NNG_OPT_RECONNMAXT` | `nng_duration` | Maximum time [dialers][dialer] will delay before trying after failing to connect. |
| `NNG_OPT_RECONNMINT` | `nng_duration` | Minimum time [dialers][dialer] will delay before trying after failing to connect. |
| `NNG_OPT_RECVBUF`<a name="NNG_OPT_RECVBUF"></a> | `int` | Maximum number of messages to buffer locally when receiving. |
| `NNG_OPT_SENDBUF`<a name="NNG_OPT_SENDBUF"></a> | `int` | Maximum number of messages to buffer when sending messages. |
| `NNG_OPT_RECVMAXSZ`<a name="NNG_OPT_RECVMAXSZ"></a> | `size_t` | Maximum message size acceptable for receiving. Can be tuned independently on [dialers][dialer] and [listeners][listener]. |
| `NNG_OPT_RECVTIMEO`<a name="NNG_OPT_RECVTIMEO"></a> | `nng_duration` | Default timeout (ms) for receiving messages. |
| `NNG_OPT_SENDBUF`<a name="NNG_OPT_SENDBUF"></a> | `int` | Maximum number of messages to buffer when sending messages. |
| `NNG_OPT_SENDTIMEO`<a name="NNG_OPT_SENDTIMEO"></a> | `nng_duration` | Default timeout (ms) for sending messages. |
&nbsp;
> [!NOTE]
> The `NNG_OPT_RECONNMAXT`, `NNG_OPT_RECONNMINT`, and `NNG_OPT_RECVMAXSZ` options are just the initial defaults that [dialers][dialer]
> (and for `NNG_OPT_RECVMAXSZ` also [listeners][listener])
> will use. After the dialer or listener is created, changes to the socket's value will have no affect on that dialer or listener.
## Polling Socket Events
```c
Expand Down
4 changes: 4 additions & 0 deletions docs/ref/migrate/nng1.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ and are thus removed:

- `nng_ctx_get_string`
- `nng_ctx_set_string`
- `nng_ctx_get_uint64`
- `nng_ctx_set_uint64`
- `nng_dialer_get_ptr`
- `nng_dialer_set_ptr`
- `nng_listener_get_ptr`
Expand All @@ -153,6 +155,8 @@ and are thus removed:
- `nng_socket_set_ptr`
- `nng_socket_get_string`
- `nng_socket_set_string`
- `nng_socket_get_uint64`
- `nng_socket_set_uint64`
- `nng_stream_get_ptr`
- `nng_stream_set_ptr`
- `nng_stream_dialer_get_ptr`
Expand Down
4 changes: 0 additions & 4 deletions include/nng/nng.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,11 @@ NNG_DECL int nng_socket_id(nng_socket);
NNG_DECL int nng_socket_set_bool(nng_socket, const char *, bool);
NNG_DECL int nng_socket_set_int(nng_socket, const char *, int);
NNG_DECL int nng_socket_set_size(nng_socket, const char *, size_t);
NNG_DECL int nng_socket_set_uint64(nng_socket, const char *, uint64_t);
NNG_DECL int nng_socket_set_ms(nng_socket, const char *, nng_duration);

NNG_DECL int nng_socket_get_bool(nng_socket, const char *, bool *);
NNG_DECL int nng_socket_get_int(nng_socket, const char *, int *);
NNG_DECL int nng_socket_get_size(nng_socket, const char *, size_t *);
NNG_DECL int nng_socket_get_uint64(nng_socket, const char *, uint64_t *);
NNG_DECL int nng_socket_get_ms(nng_socket, const char *, nng_duration *);

// These functions are used to obtain a file descriptor that will poll
Expand Down Expand Up @@ -465,14 +463,12 @@ NNG_DECL int nng_ctx_sendmsg(nng_ctx, nng_msg *, int);
NNG_DECL int nng_ctx_get_bool(nng_ctx, const char *, bool *);
NNG_DECL int nng_ctx_get_int(nng_ctx, const char *, int *);
NNG_DECL int nng_ctx_get_size(nng_ctx, const char *, size_t *);
NNG_DECL int nng_ctx_get_uint64(nng_ctx, const char *, uint64_t *);
NNG_DECL int nng_ctx_get_ms(nng_ctx, const char *, nng_duration *);

NNG_DECL int nng_ctx_set(nng_ctx, const char *, const void *, size_t);
NNG_DECL int nng_ctx_set_bool(nng_ctx, const char *, bool);
NNG_DECL int nng_ctx_set_int(nng_ctx, const char *, int);
NNG_DECL int nng_ctx_set_size(nng_ctx, const char *, size_t);
NNG_DECL int nng_ctx_set_uint64(nng_ctx, const char *, uint64_t);
NNG_DECL int nng_ctx_set_ms(nng_ctx, const char *, nng_duration);

// nng_alloc is used to allocate memory. It's intended purpose is for
Expand Down
24 changes: 0 additions & 24 deletions src/nng.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,6 @@ nng_ctx_get_size(nng_ctx id, const char *n, size_t *v)
return (ctx_get(id, n, v, NULL, NNI_TYPE_SIZE));
}

int
nng_ctx_get_uint64(nng_ctx id, const char *n, uint64_t *v)
{
return (ctx_get(id, n, v, NULL, NNI_TYPE_UINT64));
}

int
nng_ctx_get_ms(nng_ctx id, const char *n, nng_duration *v)
{
Expand Down Expand Up @@ -438,12 +432,6 @@ nng_ctx_set_size(nng_ctx id, const char *n, size_t v)
return (ctx_set(id, n, &v, sizeof(v), NNI_TYPE_SIZE));
}

int
nng_ctx_set_uint64(nng_ctx id, const char *n, uint64_t v)
{
return (ctx_set(id, n, &v, sizeof(v), NNI_TYPE_UINT64));
}

int
nng_ctx_set_ms(nng_ctx id, const char *n, nng_duration v)
{
Expand Down Expand Up @@ -1062,12 +1050,6 @@ nng_socket_set_size(nng_socket id, const char *n, size_t v)
return (socket_set(id, n, &v, sizeof(v), NNI_TYPE_SIZE));
}

int
nng_socket_set_uint64(nng_socket id, const char *n, uint64_t v)
{
return (socket_set(id, n, &v, sizeof(v), NNI_TYPE_UINT64));
}

int
nng_socket_set_ms(nng_socket id, const char *n, nng_duration v)
{
Expand Down Expand Up @@ -1106,12 +1088,6 @@ nng_socket_get_size(nng_socket id, const char *n, size_t *v)
return (socket_get(id, n, v, NULL, NNI_TYPE_SIZE));
}

int
nng_socket_get_uint64(nng_socket id, const char *n, uint64_t *v)
{
return (socket_get(id, n, v, NULL, NNI_TYPE_UINT64));
}

int
nng_socket_get_ms(nng_socket id, const char *n, nng_duration *v)
{
Expand Down

0 comments on commit c0b1557

Please sign in to comment.