项目作者: lpgauth

项目描述 :
High-Performance Erlang Cassandra CQL Client
高级语言: Erlang
项目地址: git://github.com/lpgauth/marina.git
创建时间: 2015-02-10T16:02:50Z
项目社区:https://github.com/lpgauth/marina

开源协议:MIT License

下载


marina

High-Performance Erlang Cassandra / Scylla CQL Client

Requirements

  • Cassandra 2.1+
  • Erlang 19.0+

Features

  • Authentication support
  • Compression support (LZ4)
  • CQL spec 3.2.0
  • Fast pool implementation (random, round_robin)
  • Load-balancing policies (random, token_aware)
  • Performance optimized
  • Prepared statement cache

Environment variables










































































Name Type Default Description
bootstrap_ips [list()] [“5.5.5.5”, “5.5.5.6”] ips used to bootstrap the pool
compression boolean() false enable lz4 compression
keyspace undefined | binary() undefined default keyspace
password binary() undefined password for authentication
pool_size pos_integer() 16 number of connections per node
port pos_integer() 9042 server port
reconnect boolean() true reconnect closed connections
reconnect_time_max pos_integer() | infinity 120000 reconnect maximum time
reconnect_time_min pos_integer() 1500 reconnect minimum time
strategy random | token_aware token_aware load balancing strategy across nodes
username binary() undefined username for authentication

Bootstraping

The pool is bootstraped by querying the system.peers table. marina will try each ip from boostrap_ips until it can connect and retrieve the list of peers. For backward compatibility, ip will be used if bootstrap_ips is not provided.

Examples

  1. 1> marina_app:start().
  2. {ok,[granderl,metal,shackle,foil,marina]}
  3. 2> marina:query(<<"SELECT * FROM test.users LIMIT 1;">>, #{timeout => 1000}).
  4. {ok,{result,{result_metadata,4,
  5. [{column_spec,<<"test">>,<<"users">>,<<"key">>,uid},
  6. {column_spec,<<"test">>,<<"users">>,<<"column1">>,varchar},
  7. {column_spec,<<"test">>,<<"users">>,<<"column2">>,varchar},
  8. {column_spec,<<"test">>,<<"users">>,<<"value">>,blob}],
  9. undefined},
  10. 1,
  11. [[<<153,73,45,254,217,74,17,228,175,57,88,244,65,16,117,125>>,
  12. <<"test">>,<<"test2">>,
  13. <<0,0,0,0>>]]}}
  14. }}
  15. 3> marina:query(<<"SELECT * FROM test.users WHERE key = ?;">>,
  16. #{values => [<<153,73,45,254,217,74,17,228,175,57,88,244,65,16,117,125>>],
  17. skip_metadata => true, timeout => 1000}).
  18. {ok,{result,{result_metadata,4,[],undefined},
  19. 1,
  20. [[<<153,73,45,254,217,74,17,228,175,57,88,244,65,16,117,
  21. 125>>,
  22. <<"test">>,<<"test2">>,
  23. <<0,0,0,0>>]]}}
  24. 4> {ok, Ref} = marina:async_reusable_query(<<"SELECT * FROM test.users WHERE key = ?;">>,
  25. #{values => [<<207,85,107,110,157,137,17,226,167,153,120,43,203,102,219,173>>]}).
  26. {ok,{'marina_df74df08-e5bc-42e8-af61-c24dfeda6f2c_5',#Ref<0.1577389904.1118830594.250171>}}
  27. 5> marina:receive_response(Ref).
  28. {ok,{result,{result_metadata,4,
  29. [{column_spec,<<"test">>,<<"users">>,<<"key">>,uid},
  30. {column_spec,<<"test">>,<<"users">>,<<"column1">>,varchar},
  31. {column_spec,<<"test">>,<<"users">>,<<"column2">>,varchar},
  32. {column_spec,<<"test">>,<<"users">>,<<"value">>,blob}],
  33. undefined},
  34. 0,[]}}

Tests

  1. make dialyzer
  2. make eunit
  3. make xref

TODOs

  • Batch queries
  • Rebuild ring when topology changes

License

  1. The MIT License (MIT)
  2. Copyright (c) 2015-2024 Louis-Philippe Gauthier
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.