You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add CHASM Visibility registration and task processing (#8491)
## What changed?
Adds CHASM search attribute provider and mapper implementation. To use
CHASM search attributes, embed your component with
ComponentSearchAttributesProvider and register the search attributes to
the CHASM Registry.
To define a component search attribute, define a SearchAttribute as a
package/global scoped variable (CHASM search attributes should reference
exported variables like `SearchAttributeFieldInt01`,
`SearchAttributeFieldDateTime01`:
```
var (
TestComponentStartTimeSearchAttribute = NewSearchAttributeTime(testComponentStartTimeSAKey, SearchAttributeFieldDateTime01)
_ VisibilitySearchAttributesProvider = (*TestComponent)(nil)
_ VisibilityMemoProvider = (*TestComponent)(nil)
_ VisibilitySearchAttributesMapper = (*TestComponent)(nil)
)
```
To update SearchAttributes during an execution of a CHASM archetype,
implement the provider `SearchAttributes` in the root component, and
call the `NewValue` method on a SearchAttribute within the Provider
method to generate a new SearchAttributeValue. On SearchAttribute
updates during CHASM transactions, the framework will detect changes and
submit a Visibility task for persistence.
```
type TestComponent struct {
UnimplementedComponent
...
Visibility Field[*Visibility]
}
func (tc *TestComponent) SearchAttributes(ctx Context) []SearchAttributeValue {
return []SearchAttributeValue{
TestComponentStartTimeSearchAttribute.NewValue(time)
}
}
```
To register the search attribute with the CHASM Registry,
`WithSearchAttributes` must be passed as a RegistrableComponentOption to
the root component of the library. This is required to support
Visibility queries.
```
return []*chasm.RegistrableComponent{
chasm.NewRegistrableComponent[*Scheduler]("scheduler", WIthSearchAttributes([]SearchAttributeDefinition{TestComponentStartTimeSearchAttribute}),
chasm.NewRegistrableComponent[*Generator]("generator"),
chasm.NewRegistrableComponent[*Invoker]("invoker"),
chasm.NewRegistrableComponent[*Backfiller]("backfiller"),
}
```
## Why?
Required to support CHASM Search Attributes.
## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)
## Potential risks
TBD
---------
Co-authored-by: Rodrigo Zhou <[email protected]>
0 commit comments