Class: ElasticGraph::SchemaDefinition::Scripting::Script
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaDefinition::Scripting::Script
- Defined in:
- lib/elastic_graph/schema_definition/scripting/script.rb
Instance Method Summary collapse
-
#id ⇒ Object
The id we use when storing the script in the datastore.
-
#scoped_name ⇒ Object
The ‘name` scoped with the `context`.
- #to_artifact_payload ⇒ Object
Instance Method Details
#id ⇒ Object
The id we use when storing the script in the datastore. The id is based partially on a hash of the source code to make script safely evolveable: when the source code of a script changes, its id changes, and the old and new versions continue to be accessible in the datastore, allowing old and new versions of the deployed ElasticGraph application to be running at the same time (as happens during a zero-downtime rolled-out deploy). Scripts are invoked by their id, so we can trust that when the code tries to use a specific version of a script, it’ll definitely use that version.
24 25 26 |
# File 'lib/elastic_graph/schema_definition/scripting/script.rb', line 24 def id @id ||= "#{context}_#{name}_#{::Digest::MD5.hexdigest(source)}" end |
#scoped_name ⇒ Object
The ‘name` scoped with the `context`. Due to how we structure static scripts on the file system (nested under a directory that names the `context`), a given `name` is only guaranteed to be unique within the scope of a given `context`. The `scoped_name` is how we will refer to a script from elsewhere in the code when we want to use it.
32 33 34 |
# File 'lib/elastic_graph/schema_definition/scripting/script.rb', line 32 def scoped_name @scoped_name ||= "#{context}/#{name}" end |
#to_artifact_payload ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/elastic_graph/schema_definition/scripting/script.rb', line 36 def to_artifact_payload { "context" => context, "script" => { "lang" => language, "source" => source } } end |