alexzel / iomem

Memcached client implementing binary protocol with native multiple keys support
MIT License
11 stars 1 forks source link

Add support for auto discovery of Amazon Elasticache cluster #27

Closed snowtorious closed 1 year ago

snowtorious commented 1 year ago

Amazon Elasticache provides an "auto discovery" mechanism which allows client programs to automatically identify all of the nodes in a cache cluster, and to initiate and maintain connections to all of these nodes. Some other client libraries support this. This feature would be a useful addition to iomem.

Additional context Adding Auto Discovery To Your Client Library

alexzel commented 1 year ago

Thank you for the feature suggestion. It seems like not a part of the standard Memcached protocol. I wonder if it can be implemented as a wrapper around this library. If you strongly feel that it has to be here, I would really appreciate any help with the code changes. For now I'm adding this request into v2.0.0 discussion, so we can revisit it later.

snowtorious commented 1 year ago

Yes, I think it could be implemented as a wrapper. I attempted to do this by sending the config get command like so:

client._net.query(['config', 'get', 'cluster'])

However, this appears to fail due to config get not being defined in protocol.js. This makes sense as iomem uses the binary protocol. Perhaps a list of additional opcodes could be provided to the client? (Opcode for config get command is 0x60.)

alexzel commented 1 year ago

yes, you need to change it in some places (actually a lot) https://gist.github.com/alexzel/cfbfcd79d9816253cbca48b7b4404baa