Giter VIP home page Giter VIP logo

storage-client's Introduction

Scala storage client Build Version

Finally-tagless implementation of client for misc. storages represented by backends. Supports backends fallbacks.

Currently supported backends:

  1. HCP

Dependency

Use dependency from README of selected backend:

compile "com.avast.clients.storage:storage-client-BACKEND_2.13:x.x.x"

Usage

The library has two levels:

  1. Storage client which contains so called backend
  2. Storage backend which is actual storage connector

The client has only single backend inside however backends are combinable to provide fallback support:

val backend1: StorageBackend[F] = ???
val backend2: StorageBackend[F] = ???

val merged: StorageBackend[F] = backend1 withFallbackTo backend2

Retries etc.

Retries and similar functionality is not supported out-of-the-box by the library but you can easily implement them by your own by using some F[_] which is capable of doing it and is familiar to you.

Example for monix.eval.Task:

import better.files.File
import com.avast.clients.storage.{GetResult, HeadResult, StorageBackend, StorageException}
import com.avast.scala.hashes.Sha256
import monix.eval.Task
val backend: StorageBackend[Task] = ???

val retried = new StorageBackend[Task] {
  override def head(sha256: Sha256): Task[Either[StorageException, HeadResult]] = backend.head(sha256).onErrorRestart(3)
  
  override def get(sha256: Sha256, dest: File): Task[Either[StorageException, GetResult]] = backend.get(sha256, dest).onErrorRestart(3)
  
  override def close(): Unit = backend.close()
}

Example

Example usage for monix.eval.Task:

import com.avast.clients.storage.{StorageBackend, StorageClient}
import monix.eval.Task
import monix.execution.Scheduler

implicit val scheduler: Scheduler = ???
val backend: StorageBackend[Task] = ???

val client = StorageClient(backend)

storage-client's People

Watchers

 avatar

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.