User Gateway Drivers

User gateways implement HTTP clients. When an application reads data, the user gateway issues an HTTP GET to one or more gateways to fetch the relevant chunks. When an application writes data, the user gateway issues an HTTP POST to one or more gateways to save the data (as new chunks). User gateways interact with other gateways via control-plane messages, but these are not processed by the driver.

Besides the standard serialize and deserialize methods, the only method a user gateway driver implements is a method to translate a gateway-generated HTTP URL into a driver-specific HTTP URL. This is meant to give the user gateway a chance to decide which gateways or intermediate services (like CDNs) to use for fetching a chunk. While Syndicate gateways use a standard URL format for addressing chunks of data, the intermediate networks that serve these chunks may require a specific URL format in order to be used. For example, a driver that fetches chunks from the Coral CDN would need to append to the URL’s host.

User gateway drivers are implemented within stand-alone chassis processes. When a user gateway starts, it instantiates one or more ug-driver subprocesses to execute a signle driver method:

Each ug-driver process loads the gateway owner’s driver, configuration, and secrets. Depending on the mode of operation, only one of the driver methods will be called:

Driver chassis mode Driver method called
ug-driver cdn_url cdn_url(request, syndicate_url)
ug-driver serialize serialize(request, chunk)
ug-driver deserialize deserialize(request, chunk)

Each ug-driver chassis process is long-lived–it will run until the user gateway process terminates, or until the gateway owner changes the driver code (in which case the user gateway process stops them and re-starts them with the new code).

URL Format

User gateways address manifests and blocks as follows.

A manifest URL has the format:



A block URL has the format:



Interpreting the URL fields

The fields ${timestamp_sec} and ${timestamp_nsec} in the manifest URL increment monotonically each time a file is written and published. They are set by the user gateway executing the write, and are discovered and used by user gateways to read the file. The MS stores the current manifest timestamp.

The ${version} field increments monotonically every time the file is truncated or renamed, and whenever the file’s coordinator gateway changes.

The ${block_version} field is randomly-generated each time the block contents change. It is derived from the manifest itself for the file.

The fields ${volume_id} and ${file_id_hex} are consistent throughout the file’s lifetime.

The field ${fs_path} will change only when the file is renamed.

Generating URLs

The user gateway code will send either a manifest URL or a block URL to the ug-driver process just before it issues an HTTP GET request with it. One of the ug-driver cdn_url driver chassis processes will be selected, and its cdn_url() method will be called.

The cdn_url() method takes a SG_messages::DriverRequest object and the URL as its arguments. The driver request object contains the parsed fields of the URL, which the driver code can access via the methods in the syndicate.util.gateway package.

The method must return a URL on success, or None on error. If the method returns None, then the user gateway’s read operation fails.