Giter VIP home page Giter VIP logo

marina's Introduction

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> marina_app:start().

{ok,[granderl,metal,shackle,foil,marina]}

2> marina:query(<<"SELECT * FROM test.users LIMIT 1;">>, #{timeout => 1000}).

{ok,{result,{result_metadata,4,
    [{column_spec,<<"test">>,<<"users">>,<<"key">>,uid},
     {column_spec,<<"test">>,<<"users">>,<<"column1">>,varchar},
     {column_spec,<<"test">>,<<"users">>,<<"column2">>,varchar},
     {column_spec,<<"test">>,<<"users">>,<<"value">>,blob}],
    undefined},
    1,
    [[<<153,73,45,254,217,74,17,228,175,57,88,244,65,16,117,125>>,
      <<"test">>,<<"test2">>,
      <<0,0,0,0>>]]}}
}}

3> marina:query(<<"SELECT * FROM test.users WHERE key = ?;">>,
    #{values => [<<153,73,45,254,217,74,17,228,175,57,88,244,65,16,117,125>>],
    skip_metadata => true, timeout => 1000}).

{ok,{result,{result_metadata,4,[],undefined},
    1,
    [[<<153,73,45,254,217,74,17,228,175,57,88,244,65,16,117,
        125>>,
      <<"test">>,<<"test2">>,
      <<0,0,0,0>>]]}}

4> {ok, Ref} = marina:async_reusable_query(<<"SELECT * FROM test.users WHERE key = ?;">>,
    #{values => [<<207,85,107,110,157,137,17,226,167,153,120,43,203,102,219,173>>]}).

{ok,{'marina_df74df08-e5bc-42e8-af61-c24dfeda6f2c_5',#Ref<0.1577389904.1118830594.250171>}}

5> marina:receive_response(Ref).

{ok,{result,{result_metadata,4,
    [{column_spec,<<"test">>,<<"users">>,<<"key">>,uid},
     {column_spec,<<"test">>,<<"users">>,<<"column1">>,varchar},
     {column_spec,<<"test">>,<<"users">>,<<"column2">>,varchar},
     {column_spec,<<"test">>,<<"users">>,<<"value">>,blob}],
        undefined},
            0,[]}}

Tests

make dialyzer
make eunit
make xref

TODOs

  • Batch queries
  • Rebuild ring when topology changes

License

The MIT License (MIT)

Copyright (c) 2015-2024 Louis-Philippe Gauthier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

marina's People

Contributors

haguenau avatar lpgauth avatar rattab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

marina's Issues

Plaintext cassandra implementation

It would be at least necessary to have simple platintext authentication. I have a prototype implementation neeraj9@243ff70 but is just a simple hack to authenticate. I have tested the patch against cassandra server as well and it works.

Connection leak when seed DNS record has multiple IPs

When we started using a multi rack cassandra cluster, we populated the cassandra seed DNS (A) record with one IP from each rack. We instantly saw network connections continuously climbing from the erlang hosts to the seed hosts. We reverted the DNS record to have only one IP and the connections stopped increasing.

shard-aware implementation.

Hi Lg,

Thank you for this amazing driver,
recently am working on modified elixir driver on top of GenStage, now looking to add the shard-aware feature to the driver, but I need a little help to figure out the right way to implement it.
https://github.com/scylladb/scylla/blob/master/docs/protocol-extensions.md
as you know Scylla is shared nothing model, which fit perfectly into erlang/elixir world
The goal of shard-aware is to have one connection per shard(core), this way we can send queries directly to the core which will process it( this will save cpu cycles and IPC bandwidth).
imagine this flow : lookup(token) gives -> GenStage producers ( producers number for a given token depends on the replication factor) -> The producer/s process it and pass it as batch query to consumer/s who will send to the socket(which will process it right away as the full batch belong to this logical core).

Can we discuss this pls ?

Thank you

Marina Pool is not starting

Here's my sys.config
{marina, [ {bootstrap_ips, ["192.168.2.13"]}, { keyspace, "test" }, { pool_size, 1 }, { username, "test"}, { password, "test"} ]}

I added marina_app:start() in my app.
But I am facing below error
21:11:07.407 [warning] ['marina_192.168.2.13'] handle_data error: error:function_clause [{marina_utils,use_keyspace,["test",#Port<0.1620>],[{file,"src/marina_utils.erl"},{line,164}]},{marina_client,setup,2,[{file,"src/marina_client.erl"},{line,40}]},{shackle_server_utils,client,5,[{file,"src/shackle_server_utils.erl"},{line,117}]},{shackle_tcp_server,handle_msg,2,[{file,"src/shackle_tcp_server.erl"},{line,172}]},{metal,loop,4,[{file,"src/metal.erl"},{line,88}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]
Any pointers would be highly appreciated.

Thanks Sammy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.