Class: OpenC3::HostInterfaceMicroserviceModel

Inherits:
Model show all
Defined in:
lib/openc3/models/host_interface_microservice_model.rb

Overview

Captures the information openc3-app needs to spawn a COSMOS interface on the host computer (outside Docker) so it can reach hardware such as serial ports that aren't available inside a container. A host microservice performs raw data transfer and basic functionality only; complex processing (protocols, target definitions) stays on the Docker side of COSMOS. The host side speaks Iroh back to openc3-app which forwards the data into COSMOS through the named bridge_microservice relay.

This model is written by InterfaceModel#deploy for bridged interfaces (those configured with the BRIDGE keyword) and read by openc3-app. It is deliberately kept separate from MicroserviceModel so it is NOT run by the normal COSMOS microservice operator.

Constant Summary collapse

PRIMARY_KEY =
'openc3_host_interface_microservices'

Instance Attribute Summary collapse

Attributes inherited from Model

#name, #plugin, #scope, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#check_disable_erb, #create, #deploy, #destroy, #destroyed?, #diff, filter, find_all_by_plugin, from_json, get_all_models, get_model, handle_config, set, store, store_queued, #undeploy, #update

Constructor Details

#initialize(name:, bridge_name:, stream:, config_params: [], work_dir: '.', env: {}, options: [], secret_options: [], protocols: [], secrets: [], container: nil, needs_dependencies: false, updated_at: nil, plugin: nil, scope:) ⇒ HostInterfaceMicroserviceModel

END NOTE



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 63

def initialize(
  name:,
  bridge_name:,
  stream:,
  config_params: [],
  work_dir: '.',
  env: {},
  options: [],
  secret_options: [],
  protocols: [],
  secrets: [],
  container: nil,
  needs_dependencies: false,
  updated_at: nil,
  plugin: nil,
  scope:
)
  super("#{scope}__#{PRIMARY_KEY}", name: name, updated_at: updated_at, plugin: plugin, scope: scope)
  @bridge_name = bridge_name
  @stream = stream
  @config_params = config_params
  @work_dir = work_dir
  @env = env
  @options = options
  @secret_options = secret_options
  @protocols = protocols
  @secrets = secrets
  @container = container
  @needs_dependencies = needs_dependencies
end

Instance Attribute Details

#bridge_nameObject

The bridge (bridge_microservice relay) this host interface routes through.



43
44
45
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 43

def bridge_name
  @bridge_name
end

#config_paramsObject

The real interface class and its parameters, e.g. ['serial_interface.py', ...]



33
34
35
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 33

def config_params
  @config_params
end

#containerObject

Returns the value of attribute container.



40
41
42
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 40

def container
  @container
end

#envObject

Returns the value of attribute env.



35
36
37
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 35

def env
  @env
end

#needs_dependenciesObject

Returns the value of attribute needs_dependencies.



41
42
43
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 41

def needs_dependencies
  @needs_dependencies
end

#optionsObject

Returns the value of attribute options.



36
37
38
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 36

def options
  @options
end

#protocolsObject

Returns the value of attribute protocols.



38
39
40
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 38

def protocols
  @protocols
end

#secret_optionsObject

Returns the value of attribute secret_options.



37
38
39
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 37

def secret_options
  @secret_options
end

#secretsObject

Returns the value of attribute secrets.



39
40
41
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 39

def secrets
  @secrets
end

#streamObject

The Iroh ALPN stream name (the interface name) used to route data back to openc3-app and on to the matching COSMOS bridge_interface.



46
47
48
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 46

def stream
  @stream
end

#work_dirObject

Returns the value of attribute work_dir.



34
35
36
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 34

def work_dir
  @work_dir
end

Class Method Details

.all(scope:) ⇒ Object



58
59
60
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 58

def self.all(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

.get(name:, scope:) ⇒ Object

NOTE: The following three class methods are reimplemented (like other scoped models) so the ModelController and Model class methods work.



50
51
52
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 50

def self.get(name:, scope:)
  super("#{scope}__#{PRIMARY_KEY}", name: name)
end

.names(scope:) ⇒ Object



54
55
56
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 54

def self.names(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

Instance Method Details

#as_json(*a) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/openc3/models/host_interface_microservice_model.rb', line 94

def as_json(*a)
  {
    'name' => @name,
    'scope' => @scope,
    'bridge_name' => @bridge_name,
    'stream' => @stream,
    'config_params' => @config_params,
    'work_dir' => @work_dir,
    'env' => @env,
    'options' => @options,
    'secret_options' => @secret_options,
    'protocols' => @protocols,
    'secrets' => @secrets.as_json(*a),
    'container' => @container,
    'needs_dependencies' => @needs_dependencies,
    'plugin' => @plugin,
    'updated_at' => @updated_at
  }
end