WriteThruProxy

From OpenCog

The WriteThruProxyNode is a ProxyNode that passes on requests involving the storing of Atoms and Values. This includes `store-atom`, `store-value`, and `store-referrers`. This is a mirroring proxy: if there is more than one target, the write will be made to all of them.

The primary use of this proxy is for data-sharing and data-forwarding. Incoming write requests can be passed on to all parties that are interested in that write.

Example

Suppose you want to mirror data writes to three different databases. The following will create a proxy that will write to all three:

  (ProxyParameters
     (WriteThruProxy "write-thru mirror")
     (List
        (RocksStorageNode "rocks:///tmp/foo.rdb")
        (RocksStorageNode "rocks:///tmp/bar.rdb")
        (RocksStorageNode "rocks:///tmp/fizz-buzz.rdb"))))

To actually use this, open the proxy just like any other StorageNode:

(cog-open (WriteThruProxy "write-thru mirror"))

Then you can store data:

(store-atom (Concept "foo"))

which will store all of the Values on (Concept "foo") to all three databases.

The StorageNodes in the list can be any other StorageNodes, or even other Proxies. So, for example, this will work:

  (ProxyParameters
     (WriteThruProxy "wild and crazy mirror")
     (List
        (RocksStorageNode "rocks:///tmp/foo.rdb")
        (CogStorageNode "cog://example.com:17001")
        (WriteThruProxy "up to your imagination"))))


See /examples/atomspace/persist-proxy.scm for a working example involving the CogServer.

See also