Skip to content

Edefritz/scala-tile38

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-tile38 (WIP)

This is an async tile38 client written in Scala. It abstracts away the complexity of implementing the redis protocol and compose tile38 commands by hand. Instead, you get a convenient API to interact with tile38.

Version 1 uses the cats-effect library to provide a more functional approach to async programming in Scala.

This is a work in progress. Feel free to test and play around with it, but I wouldn't recommend using it in a prod environment.

Example

// configure connection to tile38
val connection               = "redis://localhost:9851"
val client: Tile38Client[IO] = Tile38Client.forAsync[IO](connection)

for {
  _      <- client.exec(SetCommand(key = "fleet", id = "1", inputFormat = Point(1, 2)))
  result <- client.exec(GetCommand(key = "fleet", id = "1", outputFormat = GetCommand.Object))
  _      <- IO.delay(print(result))
} yield ExitCode.Success

/*

ObjectResponse(true,8.208µs,{
  "type" : "Point",
  "coordinates" : [
  2,
  1
  ]
})
  
 */

Supported Commands

  • SET
  • GET
  • SCAN
  • OUTPUT
  • TTL

Installation

Add dependency to your build.sbt

libraryDependencies += "io.github.edefritz" % "scala-tile38" % "1.0.0-alpha1"

Test

# Run both unit & integration tests
# needs docker
> make test

# or without docker
> tile38-server
> sbt test

Further development

This project started as a pet project to get a better understanding of Scala. While it works in theory there are some issues that need to be resolved so it becomes useful.

  • Coverage of possible commands is like 50%. There are a lot more tha could be added: https://tile38.com/commands
  • There is no support for LEADER / FOLLOWER setup
  • It would be nice if the pipeline could run the tests publish the artifacts automatically
  • For a good reference client library in python: https://github.com/iwpnd/pyle38

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published