3dtoolkit-server-store
database that tracks active 3dtookit servers
Last updated 2 years ago by tpark .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install 3dtoolkit-server-store 
SYNC missed versions from official npm registry.

server-store

A module used by the orchestration service of the 3dtoolkit to managed the shared state around active vms handing webrtc servers.

Installation

$ npm install --save 3dtoolkit-server-store

Initialization

The module exposes a class, ServerStore. Instances of this class requires initialization to setup the database client via the init method with the options below. Only cosmosDbEndpoint and cosmosDbKey are required, the others, if not provided, will default to the values below.

let serverStore = new ServerStore();

let options = {
    cosmosDbEndpoint: <CosmosDB endpoint>,
    cosmosDbKey: <CosmosDB key>,
    databaseName: <Database Name>, // defaults to '3dtoolkit'
    collectionName: <Collection Name>, // defaults to 'servers'
    collectionRUs: <# of request units to provision for collection> // defaults to 1000
};

serverStore.init(options, err => {

    // ... perform actions on serverStore per below

});

serverStore.upsert(server, callback)

You can upsert servers into the store via 'upsert'. If a server exists it will be updated, otherwise it will be inserted.

// server is of the form { serverId: "...", azureServerId: "...", turnServerId: "..." }
serverStore.upsert(server, err => {
    // server has been upserted.
});

serverStore.delete(serverId, callback)

Deletes a server from the store.

serverStore.delete(serverId, err => {
    // server has been deleted.
}

getByServerId(serverId, callback)

Gets a server's entry by server id.

serverStore.getByServerId((err, servers => {
    // servers is an array of server entries
})

More usage details can be found in the unit tests.

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 3
Last Month 10
Dependencies (3)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |