Skip to content

The Zetta Codebase

Matthew Dobson edited this page Jul 29, 2016 · 1 revision

Here is a general run down of the Zetta codebase.

Zetta Codebase

Pre-work libraries

The bulk of zetta is created with libraries we've created ourselves. Here are the base libraries and orgs that you should look at and follow.

/

  • zetta.js -> Main zetta class exposed for use in scripts
  • zetta_runtime.js -> File that exposes everything for developers to consume

/bin

Directory that stores code coverage scripts and version release scripts.

/lib

Directory that holds the bulk of the zetta implementation.

  • device_registry.js -> Leveldb based registry implementation for storing devices that have been exposed by the zetta server.
  • event_broker.js -> Centralized class for gathering subscriptions from clients and apps and connecting those subscriptions to the appropriate zetta node.
  • event_socket.js -> Class that sends websocket stream messages
  • http_scout.js -> Vestigial
  • http_server.js -> The base http server that wires up the API and accepts websocket connections
  • logger.js -> Base logger class. Exposes logging functionality, and hooks to override behavior.
  • peer_client.js -> Establishes connections from a hub zetta node to a cloud zetta node.
  • peer_registry.js -> Leveldb based registry that holds information on peers that have been connected to.
  • peer_socket.js -> Recieves connections from hub zetta nodes.
  • pubsub_service.js -> Centralized places where events are gathered on a zetta server. Streams, server events, and transitions go through this to be propogated to objects in js, or to other zetta nodes via event broker.
  • query.js -> Vestigial
  • query_topic.js -> Parses device query stream topics
  • registration_resource.js -> Vestigial
  • registry.js -> Base class for the registries. Flat file leveldb. Subclass this for additional registries.
  • runtime.js -> Essentially this is the server variable passed into apps. Allows for device queries and other hooks into zetta that aren't exposed in the server file.
  • spdy_agent.js -> Subclasses default http agent in nodejs to expose the spdy socket.
  • virtual_device.js -> Abstraction for devices that are queried from another server.
  • web_socket.js -> Basic websocket implementation to move away from WS eventually.

/test

Holds our unit tests. They are written in Mocha.

/lib/api_formats/siren

Holds our API object templates. Uses the argo-formatter module

  • device.siren.js -> Device template serves the /servers/<id>/devices/<deviceId> route
  • devices.siren.js -> Device list template serves the /servers/<id>/devices route
  • metadata.siren.js -> Metadata api to describe device models /servers/<id>/devices/<type>/meta
  • server.siren.js -> Server template serves the /servers/<id> route
  • type.siren.js ->

/lib/api_resources

Holds our API resource business logic. Uses the argo-resource module

  • devices.js -> Devices route handler
  • peer_management.js -> Peer management route handler
  • root.js -> Root route handler
  • servers.js -> Servers route handler
Clone this wiki locally