carwynmoore / perl-nats

A Perl client for the NATS messaging system
MIT License
12 stars 6 forks source link

timeout for wait_for_op() method; implement subscription->unsubscribe() #1

Closed khera closed 8 years ago

khera commented 8 years ago

The unsubscribe method is documented in the README but did not in reality exist.

The timeout in wait_for_op() is useful when doing a work loop interacting with other services.

carwynmoore commented 8 years ago

Thanks for the update, timeouts were really needed.

khera commented 8 years ago

It seems that this timeout is badly implemented. In trivial case it does work, but it does get into a state where the buffered I/O from getline() has data to return already buffered, but there's no way to probe for that. The select() call just stalls waiting for more data from the network, which may never come, and the data that is in the I/O buffer never gets processed.

I'm trying to figure out a better way to do this. If all calls for I/O were via getline, then there are easy patterns to do it; however we need a mix of getline() and read(), which is making this harder, but not impossible.

I think all input will have to be done in terms of sysread with a self-managed buffer for providing the line-oriented getlnie() emulation.