Class: Cybertrain::WebSocket::StatusWriter

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/websocket/status_writer.rb

Overview

Where publish_status writes a feed’s status row. The default writes nothing; cybertrain/websocket/feed_table.rb registers the one that writes cybertrain_feeds (FeedTable), and cybertrain/feeds requires it. cybertrain/websocket requires cybertrain/feeds (and so the core, with SQLite), so every program that subscribes publishes; require "cybertrain/websocket" no longer loads under CRuby or without the database (docs/design.md D85). The registry keeps the frame and client files free of the table. The same pattern as Background::Service: a base-class registry, a subclass instance added by the file that has the real one.

Direct Known Subclasses

FeedTableWriter

Instance Method Summary collapse

Instance Method Details

#status_withdraw(process) ⇒ Integer

Deletes the rows process wrote (its feeds were stopped cleanly).

Parameters:

  • process (String) —

    “:"

Returns:

  • (Integer) —

    how many rows it deleted



33
34
35
# File 'cybertrain/websocket/status_writer.rb', line 33

def status_withdraw(process)
  0
end

#status_write(name, process, connected, started_at, last_activity_at, restarts, now) ⇒ Boolean

Writes one feed’s row.

Parameters:

  • name (String) —

    the subscription’s name

  • process (String) —

    “:"

  • connected (Boolean)
  • started_at (Integer) —

    epoch seconds

  • last_activity_at (Integer) —

    epoch seconds, 0 for none yet

  • restarts (Integer)
  • now (Integer) —

    epoch seconds, the row’s updated_at

Returns:

  • (Boolean) —

    true when it wrote the row



25
26
27
# File 'cybertrain/websocket/status_writer.rb', line 25

def status_write(name, process, connected, started_at, last_activity_at, restarts, now)
  false
end