Molecule
Molecule copied to clipboard
Feature : Starting a Component Cluster?
Discussed in https://github.com/OpenSmock/Molecule/discussions/33
Originally posted by labordep May 14, 2021 Starting automatically a Component Cluster composed by a set a Components Classes linked by a componentName. For example :
MolUtils startComponentsCluster: aComponentList named: aComponentName.
This method start each components classes using "aComponentName" instead of #default key and map automatticaly each of them inside the cluster.
Components are linked with the default component name without specified declaration, the component name is "#default". The cluster connexion principles are to re-use this default settings but with another component name, for example "#cluster1". When the cluster is started all components are automaticaly linked with #cluster1 key.
@ELePors don't hesitate to expose your ideas on this function to brainstorm on it.
Edit: this is a reflexion. => I don't find an use case when 'componentName' is not suffisant to deploy a component stack :/ May be this feature is a reflect of a structuration problematic and not to be managed by Molecule, but by the app designer.
An example of use:
I want to start MyComponentA implementation in two clusters.
Starting same component in two clusters:
component := MyComponentA startInNewCluster.
component componentName. "#default_cluster12542 (generated unique cluster name)"
component clusterName. "#cluster12542"
"another examples"
MyComponentA startInNewCluster. "default->cluster59634 (generated unique cluster name)"
MyComponentA startInClusterNamed: #clusterA. "default->clusterA"
MyComponentA startInClusterNamed: #clusterB. "default->clusterB"
Used this component in a ponctual cluster external component:
MyComponentAClient>>componentInitialize
self forServices: MyComponentAServices useProvider: (ComponentName default; clusterName: #cluster12542; yourself value). "need an object to build the key properly: ComponentName default; clusterName: #cluster12542; yourself value"
Used cluster deployment capacity inside a "clusterized" component. => Actual behavior, no changes. but in background check if the component belongs to a cluster:
MyComponentA>>componentInitialize
"starting some sub-component (used when a Component tree is deployed)"
MyComponentBServices start: self componentName. "component used as a cluster => #myKey_clusterX"
MyComponentCServices start. "common component used by all components: warning it is necessary to test before is this component is not already started (dirty example)"
"using sub components"
self forServices: MyComponentBServices useProvider: self componentName. "component used as a cluster => #myKey_clusterX"
self forServices: MyComponentCServices useProvider: #default "common component used by all components, not necessary to write this line, this is for example illustration (explicit)"
MolComponentImpl>>componentName
"return the cluster name or the component name"
^ self cluster ifNil:[ componentName "#componentName" ] ifNotNil:[ :c |
ComponentName name: componentName; clusterName: c name; yourself value
]
MolComponentImpl>>clusterName
"return the cluster name"
^ self cluster ifNotNil:[ :c | c name "#clusterXXX"]