Skip to content

CHASM Visibility utils#9428

Open
rodrigozhou wants to merge 2 commits intorodrigozhou/refactor-safrom
rodrigozhou/chasm-sa-util
Open

CHASM Visibility utils#9428
rodrigozhou wants to merge 2 commits intorodrigozhou/refactor-safrom
rodrigozhou/chasm-sa-util

Conversation

@rodrigozhou
Copy link
Contributor

What changed?

Add some util functions to CHASM Visibility objects.

Why?

Easy way to encode/decode search attributes map/payloads.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/refactor-sa branch from 91297fc to 0cf8e78 Compare March 2, 2026 18:25
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/chasm-sa-util branch from 82c202a to 011a740 Compare March 2, 2026 18:26
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/chasm-sa-util branch from 011a740 to 880da89 Compare March 2, 2026 18:37
@rodrigozhou rodrigozhou force-pushed the rodrigozhou/refactor-sa branch from 0cf8e78 to 1665b4a Compare March 2, 2026 18:56
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, I would just rather not export any member from the chasm package that libraries do not consume directly. And please treat any exported member as it is going to be consumed by an external contributor. We are aiming to keep the bar high on this.

return SearchAttributesMap{values: values}
}

func NewSearchAttributesMapFromProto(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not expose this from the chasm package since we don't expect libraries to use this.

Also make sure to properly document any exported function in this framework.

func (v VisibilityValueInt64) MustEncode() *commonpb.Payload {
p, _ := payload.Encode(int64(v))
sadefs.SetMetadataType(p, enumspb.INDEXED_VALUE_TYPE_INT)
p, _ := sadefs.EncodeValue(int64(v), enumspb.INDEXED_VALUE_TYPE_INT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should panic if there's an error instead of silently ignoring it.

Comment on lines 6 to 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document these.

ov, ok := other.(VisibilityValueInt)
if !ok {
return false
func VisibilityValueFromPayload(p *commonpb.Payload) (VisibilityValue, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer not to export this here.

@rodrigozhou rodrigozhou force-pushed the rodrigozhou/refactor-sa branch 3 times, most recently from 2572793 to 22af7e7 Compare March 2, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants