Adapter to plug a NATS
connection to a libuv
event loop.
◆ natsLibuv_Init()
void natsLibuv_Init |
( |
void |
| ) |
|
Needs to be called once so that the adapter can initialize some state.
◆ natsLibuv_SetThreadLocalLoop()
void natsLibuv_SetThreadLocalLoop |
( |
uv_loop_t * |
loop | ) |
|
Since libuv
is not thread-safe, the adapter needs to know in which thread uv_run()
will run for the given loop
. It allows the adapter to schedule events so that they are executed in the event loop thread.
- Parameters
-
◆ natsLibuv_Attach()
This callback is invoked after NATS
library has connected, or reconnected. For a reconnect event, *userData
will not be NULL
. This function will start polling on READ events for the given socket
.
- Parameters
-
userData | the location where the adapter stores the user object passed to the other callbacks. |
loop | the event loop as a generic pointer. Cast to appropriate type. |
nc | the connection to attach to the event loop |
socket | the socket to start polling on. |
◆ natsLibuv_Read()
natsStatus natsLibuv_Read |
( |
void * |
userData, |
|
|
bool |
add |
|
) |
| |
This callback is invoked to notify that the event library should start or stop polling for READ events.
- Parameters
-
userData | the user object created in natsLibuv_Attach |
add | true if the library needs to start polling, false otherwise. |
◆ natsLibuv_Write()
natsStatus natsLibuv_Write |
( |
void * |
userData, |
|
|
bool |
add |
|
) |
| |
This callback is invoked to notify that the event library should start or stop polling for WRITE events.
- Parameters
-
userData | the user object created in natsLibuv_Attach |
add | true if the library needs to start polling, false otherwise. |
◆ natsLibuv_Detach()
When a connection is closed (not disconnected, pending a reconnect), this callback will be invoked. This is the opportunity to cleanup the state maintained by the adapter for this connection.
- Parameters
-