All Projects → Tinkoff → aerospike-scala

Tinkoff / aerospike-scala

Licence: Apache-2.0 license
Typesafe DSL for work with Aerospike Database

Programming Languages

scala
5932 projects
Protocol Buffer
295 projects

Projects that are alternatives of or similar to aerospike-scala

flyteidl
Specification of the IR for Flyte workflows and tasks. Also Interfaces for all backend services. https://docs.flyte.org/projects/flyteidl/en/stable/
Stars: ✭ 27 (-32.5%)
Mutual labels:  protobuf
protokit
A starter kit for building protoc plugins. Rather than write your own, you can just use an existing one.
Stars: ✭ 69 (+72.5%)
Mutual labels:  protobuf
stellarstation-api
The API definition for StellarStation.
Stars: ✭ 22 (-45%)
Mutual labels:  protobuf
raster
A micro server framework, support coroutine, and parallel-computing, used for building flatbuffers/thrift/protobuf/http protocol service.
Stars: ✭ 19 (-52.5%)
Mutual labels:  protobuf
sisyphus-js
Sisyphus customized protobuf and gRPC runtime and code generator for JavaScript/TypeScript
Stars: ✭ 19 (-52.5%)
Mutual labels:  protobuf
rules proto grpc
Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
Stars: ✭ 201 (+402.5%)
Mutual labels:  protobuf
Play Store Api
Google Play Store protobuf API wrapper in java
Stars: ✭ 249 (+522.5%)
Mutual labels:  protobuf
WebApiClient.Extensions
WebApiClient项目的第三方扩展:Autofac、DependencyInjection、HttpClientFactory、SteeltoeOSS.Discovery、MessagePack、Protobuf、Json-Rpc
Stars: ✭ 73 (+82.5%)
Mutual labels:  protobuf
molch
An implementation of the axolotl ratchet based on libsodium.
Stars: ✭ 24 (-40%)
Mutual labels:  protobuf
j2cl-protobuf
Protocol Buffers implementation for J2CL
Stars: ✭ 23 (-42.5%)
Mutual labels:  protobuf
go-chat
go-chat.使用Go基于WebSocket开发的web聊天应用。单聊,群聊。文字,图片,语音,视频消息,屏幕共享,剪切板图片,基于WebRTC的P2P语音通话,视频聊天。
Stars: ✭ 516 (+1190%)
Mutual labels:  protobuf
GameTracking-HalfLifeAlyx
📥 Game Tracker: Half-Life: Alyx
Stars: ✭ 24 (-40%)
Mutual labels:  protobuf
protoc-gen-persist
GRPC SQL and Spanner persistence layer
Stars: ✭ 60 (+50%)
Mutual labels:  protobuf
golang-example-app
Example application
Stars: ✭ 138 (+245%)
Mutual labels:  protobuf
libcluon
libcluon is a small and efficient, single-file and header-only library written in modern C++ to power microservices.
Stars: ✭ 81 (+102.5%)
Mutual labels:  protobuf
JavaSteam
Java library that provides an interface to directly interact with Valve's Steam servers.
Stars: ✭ 70 (+75%)
Mutual labels:  protobuf
Meshtastic-protobufs
Protobuf definitions for the Meshtastic project
Stars: ✭ 32 (-20%)
Mutual labels:  protobuf
go2gql
graphql-go schema generator by proto files
Stars: ✭ 33 (-17.5%)
Mutual labels:  protobuf
metastore
A protobuf schema registry on steroids. It will keep track of the contracts throughout your organization, making sure no contract is broken.
Stars: ✭ 43 (+7.5%)
Mutual labels:  protobuf
MicroServicePractice
微服务实践的demo
Stars: ✭ 40 (+0%)
Mutual labels:  protobuf

aerospike-scala-dsl

N|Solid

To start working with Aerospike using this DSL you have to add dependency sbt:

"ru.tinkoff" %% "aerospike-scala" % "1.1.14",
"com.aerospike" % "aerospike-client" % "3.3.1", // in case you don't have it
"ru.tinkoff" %% "aerospike-scala-example" % "1.1.14" // usage examples
"ru.tinkoff" %% "aerospike-scala-proto" % "1.1.14" // protobuff serialization support

Since I'm using Aerospike Java Client (version 3.3.1, recomended on www.aerospike.com), you need to create com.aerospike.client.async.AsyncClient to pass it into ru.tinkoff.aerospike.dsl.SpikeImpl class. SpikeImpl has methods to operate with Aerospike for specified types of Keys and Bins, which is the most common case. Example for that object creation you can find in ru.tinkoff.aerospikeexamples.example.AClient (sh "ru.tinkoff" % "aerospike-scala-example"). Or just follow the quickstart instructions.

#Protobuf Serialization is here! Check it out!

Quickstart

Add this settings to application.conf file and specify your own host, port, namespace and setName:

ru-tinkoff-aerospike-dsl {
    keyWrapper-namespace = "test"
    keyWrapper-setName = "test"
    example-host = "somehost.com" 
    example-port = 3000
}

after that call ru.tinkoff.aerospikeexamples.example.AClient.client in your service (or something where you need to communicate with Aerospike) and pass result of that call into ru.tinkoff.aerospike.dsl.SpikeImpl:

import scala.concurrent.ExecutionContext.Implicits.global

val client = AClient.client
val spike = new SpikeImpl(client)

or you can call AClient.spikeImpl, which gives an example of SpikeImpl with host and port from ru-tinkoff-aerospike-dsl settings

 val spike = AClient.spikeImpl

Note: don't forget to add host and port in application.conf, or you will get an exception from com.aerospike.client lib:

Exception in thread "main" com.aerospike.client.AerospikeException$Connection: Error Code 11: Failed to connect to host(s): 
host 3000 Error Code 11: Invalid host: host 3000

For namespace and setName parameters add

implicit val dbc = AClient.dbc

Now you can use it like this:

import ru.tinkoff.aerospike.dsl.{CallKB, SpikeImpl}
import ru.tinkoff.aerospikeexamples.example.AClient
import ru.tinkoff.aerospikescala.domain.SingleBin
import ru.tinkoff.aerospikemacro.converters._

import scala.concurrent.Await
import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global

object HelloAerospike extends App {

  val client = AClient.client
  val spike = new SpikeImpl(client)
  implicit val dbc = AClient.dbc

  Await.result(spike.callKB(CallKB.Put, "testKey", SingleBin("helloName", "helloValue")), Duration.Inf)
}

This will Put string value "helloValue" with name "helloName" in Aerospike with Key "testKey". For that call will be generated converters, both to convert passed values into inner com.aerospike.clients values.

aql> select * from test.test
[
  {
    "helloName": "helloValue"
  }
]

All available methods you can see in SpikeImpl class by your self. For more information and usage examples cookbook.

DSL schema options

In ru.tinkoff.aerospike.dsl.scheme we have two traits:

  • for work with one key type and different types of Bins
trait Scheme[K]
  • for work with one key type and one Bin type
trait KBScheme[K, B]

If you want to work with one type of Key and different types of Bins - any Bin types If you want to work with one type of Key and one type of Bins one Bin type

Application

Implemented for ASyncClient. Recommended to use with Aerospike 3.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].