Skip to content

Latest commit

 

History

History
63 lines (37 loc) · 4.47 KB

File metadata and controls

63 lines (37 loc) · 4.47 KB

Swim Server

Swim unifies the traditionally disparate roles of database, message broker, job manager, and application server, into a few simple constructs.

Read this in other languages: 简体中文

Web Agents

Swim implements a general purpose distributed object model. The "objects" in this model are Web Agents.

Creating a class that extends swim.api.agent.AbstractAgent defines a template for Web Agents (though not a useful one until we add some lanes).

Try it yourself:

Visit the documentation for further details about Web Agents.

Lanes

If Web Agents are objects, then lanes serve as the "fields" of those objects. Lanes come in many flavors, e.g. value lanes, map lanes, and command lanes.

Continuing our analogy, lane callback functions serve as the "methods" of Web Agents.

Each lane type defines a set of overridable (default no-op) lifecycle callbacks. For example, sending a command message to any command lane will trigger its onCommand callback. On the other hand, setting a value lane will trigger its willSet callback, then update its value, then trigger its didSet callback.

Try it yourself:

  • Navigate to swim.tutorial.UnitAgent.java
  • Fill in the remaining code to create a new value lane called stats which gets populated by changes to the histogram map lane
  • Experiment with ways to transform the data entries in histogram. Ideas: mean, median, range, standard deviation, variance, etc!
  • Compare your answer with those in the solutions branch

Visit the documentation for further details about lanes.

Standing a Swim Server

A Swim server is loaded with a plane, which provides the runtime for Web Agents and routes messages to the correct lanes.

A plane must declare a SwimRoute field for each Web Agent type.

Use the ServerLoader utility class to load the default kernel modules.

Visit the documentation for further details about these concepts.

Populating a Swim Server With Your Data

Every Swim server can be written to and read from by external processes using the Swim API. The simplest way to utilize this API is to use a Swim client instance to send commands to command lanes.

Visit the documentation for further details about these concepts.

Subscribing to Swim Server Data

Swim client instances use Swim links to pull data from a Swim lanes. Like their corresponding lanes, links have overridable callback functions that can be used to populate UIs.

Visit the documentation for further details about links.

Visualizing Your Changes in the UI

  • Consider how the above changes to the server code may change the way you'd want to visualize your data
  • Navigate to the ui folder
  • Experiment with the UI code to accommodate for your server-side changes
  • See the solutions branch for an example of this