Giter Site home page Giter Site logo

erlang-one / kvs_feeds Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 5 KB

Generic KVS feed-server

License: MIT License

Erlang 100.00%
erlang mnesia riak erlang-libraries erlang-bindings kvs n2o distributed-hash-table distributed-storage distributed-database

kvs_feeds's Introduction

KVS Feeds

Generic KVS feed-server

Overview

Feed server for KVS abstract database middleware.

Implements database queries in the form of atomic operations or in other words, provides transaction for KVS-feeds logic.

Dependency

  • kvs – Database middleware.
  • n2o – n2o_async needed.

Configuration

sys.config

  • log :: {Mod,Fun} – Custom logging function/3, default: {wf,info}
  • feed_timeout :: non_neg_integer() – Pool worker timeout, in ms, default: 600000 (10 min)
  • feed_timeout_action :: hibernate | stop – Action for inactive pool workers, default: hibernate

Api

  • append(Record) – Add Record to database.
  • delete(Record) – Remove Record from database.
  • update(Record,Fun) – Update Record with Fun/1 which takes Record2 (at the time of execution) and should return {ok,Record3} (modified) if surgery is to be performed, or anything else to cancel.
  • relink(Record) – Bring Record to top in Record feed.
  • purge(Record,Fun) – Remove Record and related feeds with Fun/0 which should return a list of feeds, example: kvs_feeds:purge(E,fun() -> [{feed,attachments,fun kvs_feed:delete/1}] end), feed_id to be deleted will be generated as {attachment,element(2,E)} for feed container table.
  • eval(Record,Fun) – Eval custom Fun/1 which takes Record2 (at the time of execution), like as update/2.

Usage

R=#post{},
{ok,R2}=kvs_feeds:append(R),
Link = 1000,
FunUpdate=fun(#post{links=Links}=P) -> {ok,P#post{links=lists:usort([Link | Links])}} end,
{ok,R3}=kvs_feeds:update(R2,FunUpdate),
     ok=kvs_feeds:delete(R3),
        kvs_feeds:purge(R3,fun() -> [{feed,attachment,fun kvs_feeds:delete/1}] end),

Credits

kvs_feeds's People

Contributors

m-2k avatar

Stargazers

 avatar  avatar  avatar

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.