Module: caf_sharing/proxy_sharing

A proxy to access Shared Maps from application code.

Source:

Extends

Members

$

A context containing proxies to all the visible Shared Maps for this CA.

Application code refers to these maps using aliases:

 this.$.sharing.$.myMap

and this is typically shortened as follows:

 var $$ = this.$.sharing.$
 $$.myMap.set('x', $$.myMap.get('y') + 1)
Source:

Methods

addReadOnlyMap(alias, name, optionsopt)

Creates a read-only mirror of a Shared Map or an Aggregate Map.

The Shared Map will be active before this CA processes another message.

The consistency model is monotonic read consistency: local replicas could be stale, but once we see a Shared Map version, we will never see previous ones.

Type of caf_map.options is {isAggregate: boolean}

Parameters:
Name Type Attributes Description
alias string

A short name that identifies this map in the this.$.sharing.$ context.

name string

A fully qualified name for the source of this Shared Map, i.e., scoped with the owner's CA name, like caOwner-caLocalName-mapLocalName.

options mapOptionsType <optional>

If options.isAggregate is true create an AggregateMap.

Source:

addWritableMap(alias, name, optionsopt)

Creates, or reloads if already created, a writable Shared Map.

The map will be active before this CA processes another message.

Parameters:
Name Type Attributes Description
alias string

A short name that identifies this map in the this.$.sharing.$ context.

name string

A relative name for this map that will be scoped by this CA's name.

options mapOptionsType <optional>

Placeholder for future map customization.

Source:

applyDelta(alias, changes, loggeropt)

Applies a change set to a writable map, needed to replicate external Shared Maps.

Parameters:
Name Type Attributes Description
alias string

The local alias for this map.

changes mapUpdateType

A set of changes to apply.

logger Object <optional>

An optional logger, i.e., this.$.log, to warn of ignored updates.

Source:
Throws:

Error when the change set version is not compatible.

deleteMap(alias)

Deletes a local reference to a Shared Map.

The contents of the map are not destroyed from persistent storage.

Parameters:
Name Type Description
alias string

The local alias for this map.

Source:

fullName(name) → {string}

Gets the full name of a local writable Shared Map.

Maps are named after the CA that owns them, i.e., a complete name is caOwner-caLocalName-mapLocalName.

Parameters:
Name Type Description
name string

A relative name for a Shared Map.

Source:
Returns:

A complete name for the Shared Map.

Type
string

pullUpdate(alias, versionopt) → {mapUpdateType|Array.<mapUpdateType>}

Returns an incremental update or a full dump of the Shared Map.

The type of mapUpdateType is {version: number, remove : Array<string>, add : Array<string|Object>} where add just flattens key/value pairs in a single array.

Multiple incremental updates can be provided in an array of mapUpdateType objects.

An up to date local replica will have an empty array as update.

Parameters:
Name Type Attributes Description
alias string

The local alias for this map.

version number <optional>

The current version of the local Shared Map, or undefined if a full dump is needed.

Source:
Returns:

A full dump of the map or a list with incremental updates (empty if up to date).

Type
mapUpdateType | Array.<mapUpdateType>