Skip to content
persist actors in database
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.prettierrc
.travis.yml
CODE_OF_CONDUCT.md
LICENSE
README.md
ambient.d.ts
package.json
rollup.config.js
tsconfig.json
tslint.json
upgrade.sh
yarn.lock

README.md

logomakr_8lsyys

npm Build Status Coverage Status PRs Welcome issues Welcome npm GitHub issues GitHub pull requests Downloads

Motivation

Provide the capabilities to actors on the backend to be persisted using waterline adapters.

Installation

add it to your project using npm install tarant-db-persist --save or yarn add tarant-db-persist

Usage

Initialize the sync client with the waterline adapter from the persist storage you will be interested on

import { ActorSystem, ActorSystemConfigurationBuilder } from 'tarant';
import * as diskAdapter from 'sails-disk';
import { PersistResolverMaterializer } from 'tarant-db-persist';
import AppActor from '../AppActor';

const config = {
    adapter: {
        type: diskAdapter,
        settings: {
          inMemoryOnly: true
        },
      },
      actorTypes: { AppActor }
  };

const persister = await PersistMaterializer.create(config)

const system : any = ActorSystem.for(ActorSystemConfigurationBuilder.define()
    .withMaterializers([persister])
    .withResolvers([persister])
    .done())  

your actors will require to implement IUpdatable (UpdateFrom) and IExportable (toJson)

import { Actor } from "tarant";
import { IUpdatable, IExportable } from "tarant-db-persist"

export default class AppActor extends Actor implements IUpdatable, IExportable {

  constructor(name: string) {
      super(name)
  }

  addOne() {
      this.counter++
  }

  toJson(){
        return {
            id: this.id,
            type:"AppActor",
            counter: this.counter
        }
    }

    updateFrom({ counter }: any): void {
        this.counter = counter
    }

    private counter = 1; 
}
Created my free logo at LogoMakr.com
You can’t perform that action at this time.