Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structify Opeartor Socket #1326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

supriya-premkumar
Copy link
Contributor

Changes:
Defines a concrete type OperatorSocket
Internal state is unexported to prevent unintented changes from the importing package.
Defines Get functions to access methods

Why are these changes needed?

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@supriya-premkumar supriya-premkumar force-pushed the supriya-egda-834-refactor-structify-operatorsocket branch 2 times, most recently from 4d165f9 to c5e5ec1 Compare February 25, 2025 16:42
@supriya-premkumar supriya-premkumar self-assigned this Feb 26, 2025
v1RetrievalPort string
v2DispersalPort string
v2RetrievalPort string
}

func (s OperatorSocket) String() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Marshal/Unmarshal or Serialize/Deserialize? String() feels like producing something for logging, debugging or display.

//TODO: Add config checks for invalid v1/v2 configs -- for v1, both v2 ports must be empty and for v2, both ports must be valid, reject any other combinations.
if v2DispersalPort == "" && v2RetrievalPort == "" {
return OperatorSocket(fmt.Sprintf("%s:%s;%s", nodeIP, dispersalPort, retrievalPort))
func NewOperatorSocket(nodeIP, dispersalPort, retrievalPort, v2DispersalPort, v2RetrievalPort string) OperatorSocket {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: move factory method right above (before String())

if err != nil {
logger.Warn("Failed to parse operator socket", "err", err)
}
socket = operatorSocket.GetV1RetrievalSocket()
Copy link
Contributor

Choose a reason for hiding this comment

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

If err != nil, how can this still get v1 retrieval socket?

operatorSocket := core.OperatorSocket(operatorInfo.Socket)
operatorSocket, err := core.ParseOperatorSocket(operatorInfo.Socket)
if err != nil {
oh.logger.Warn("failed to parse operator socket", "operatorId", operatorId, "error", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

In what cases it'll fail to parse? Is that just a warning issue?

Changes:
	Defines a concrete type OperatorSocket
	Internal state is unexported to prevent unintented changes from the importing package.
	Defines Get functions to access methods
@supriya-premkumar supriya-premkumar force-pushed the supriya-egda-834-refactor-structify-operatorsocket branch from df5a7cc to d431b1e Compare February 27, 2025 05:03
@@ -40,8 +40,12 @@ func (c client) GetBlobHeader(
batchHeaderHash [32]byte,
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of taking socket parameter as string, can we take it as OperatorSocket?


func (s OperatorSocket) String() string {
return string(s)
if s.v2DispersalPort == "" && s.v2RetrievalPort == "" {
return fmt.Sprintf("%s:%s;%s", s.host, s.v1DispersalPort, s.v2RetrievalPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/s.v2RetrievalPort/s.v1RetrievalPort

should it also check if v1 ports are there?

if v2DispersalPort == "" && v2RetrievalPort == "" {
return OperatorSocket(fmt.Sprintf("%s:%s;%s", nodeIP, dispersalPort, retrievalPort))
func NewOperatorSocket(nodeIP, dispersalPort, retrievalPort, v2DispersalPort, v2RetrievalPort string) OperatorSocket {
return OperatorSocket{
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add a validation here? (i.e. host & v1 ports cannot be empty, if v2DispersalPort exists, v2RetrievalPort must exist)

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.

3 participants