How to - managing remote bindings in a GemStone snippets
GemStone snippets can define and use variable bindings. The values for these bindigs can be sent when executing code remotely, and also send to the remote side.
The main logic for handling remote bindings is handled by GtGemStoneSnippetRemoteExecutionBuilder
. This builder takes as input a set of local bindings and the code to be executed, and computes the set of bingings that need to sent to the remote side (GtGemStoneSnippetRemoteExecutionBuilder>>#remoteBindings
), and the source code that should be executed remotely (GtGemStoneSnippetRemoteExecutionBuilder>>#generateRemoteScript
) . Remote bindings are modeled as instanced of type GtGemStoneWorkspaceVariable
.
Example
As an example we can consider the following code:
From it when extracting binding if a, b and e have a value they are sent as remote binding.
Code snippets
These are code snippets for programatically creating a builder and interacting with it
Snippet with variable written first
As a first step we need to define a builder and set the local bindings
localBindings := GtSharedVariablesBindings new.
(localBindings bindingOf: #a) value: 42.
builder := GtGemStoneSnippetRemoteExecutionBuilder new localBindings: localBindings; sourceString: ' a := 1 a + 1'.
Once the builder is set we can get the remote bindings and the remote script
builder remoteBindings.
builder generateRemoteScript
Snippet with multiple variables
localBindings := GtSharedVariablesBindings new.
Set valid bindings
(localBindings bindingOf: #a) value: 42. (localBindings bindingOf: #b) value: 43. (localBindings bindingOf: #c) value: 44.
Set two invalid bindings
(localBindings bindingOf: #a) value: 42. (localBindings bindingOf: #b) value: GspoString new. (localBindings bindingOf: #c) value: GspoString new.
builder := GtGemStoneSnippetRemoteExecutionBuilder new localBindings: localBindings; sourceString: ' a + c + d '.
builder remoteBindings.
builder generateRemoteScript