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

Change bitfields from enum to uint64 #132

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/clientimpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ func TestReportAgentDescription(t *testing.T) {
// Ask client for full AgentDescription.
return &protobufs.ServerToAgent{
InstanceUid: msg.InstanceUid,
Flags: protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState,
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
}
})

Expand Down Expand Up @@ -805,7 +805,7 @@ func TestReportAgentHealth(t *testing.T) {
// Ask client for full AgentDescription.
return &protobufs.ServerToAgent{
InstanceUid: msg.InstanceUid,
Flags: protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState,
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
}
})

Expand Down Expand Up @@ -874,7 +874,7 @@ func TestReportEffectiveConfig(t *testing.T) {
// Ask client for full AgentDescription.
return &protobufs.ServerToAgent{
InstanceUid: msg.InstanceUid,
Flags: protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState,
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
}
})

Expand Down Expand Up @@ -979,7 +979,7 @@ func verifyRemoteConfigUpdate(t *testing.T, successCase bool, expectStatus *prot
return &protobufs.ServerToAgent{
InstanceUid: msg.InstanceUid,
// Ask client to report full status.
Flags: protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState,
Flags: uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState),
}
})

Expand Down Expand Up @@ -1169,7 +1169,7 @@ func verifyUpdatePackages(t *testing.T, testCase packageTestCase) {

if compressedReceived {
// Ask for full report again.
response.Flags = protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState
response.Flags = uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState)
} else {
// Keep triggering status report by setting AgentDescription
// until the compressed PackageStatuses arrives.
Expand Down
2 changes: 1 addition & 1 deletion client/internal/clientcommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (c *ClientCommon) PrepareFirstMessage(ctx context.Context) error {
msg.EffectiveConfig = cfg
msg.RemoteConfigStatus = c.ClientSyncedState.RemoteConfigStatus()
msg.PackageStatuses = c.ClientSyncedState.PackageStatuses()
msg.Capabilities = c.Capabilities
msg.Capabilities = uint64(c.Capabilities)
},
)
return nil
Expand Down
2 changes: 1 addition & 1 deletion client/internal/receivedprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (r *receivedProcessor) ProcessReceivedMessage(ctx context.Context, msg *pro
return
}

scheduled, err := r.rcvFlags(ctx, msg.Flags)
scheduled, err := r.rcvFlags(ctx, protobufs.ServerToAgentFlags(msg.Flags))
if err != nil {
r.logger.Errorf("cannot processed received flags:%v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/examples/server/data/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (agent *Agent) updateEffectiveConfig(
}

func (agent *Agent) hasCapability(capability protobufs.AgentCapabilities) bool {
return agent.Status.Capabilities&capability != 0
return agent.Status.Capabilities&uint64(capability) != 0
}

func (agent *Agent) processStatusUpdate(
Expand Down Expand Up @@ -227,7 +227,7 @@ func (agent *Agent) processStatusUpdate(
if statusIsCompressed && lostPreviousUpdate {
// The status message is not fully set in the message that we received, but we lost the previous
// status update. Request full status update from the agent.
response.Flags |= protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState
response.Flags |= uint64(protobufs.ServerToAgentFlags_ServerToAgentFlags_ReportFullState)
}

configChanged := false
Expand Down
10 changes: 5 additions & 5 deletions internal/proto/opamp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ message AgentToServer {
// in the future such that old Agents automatically report that they don't
// support the new capability.
// This field MUST be always set.
AgentCapabilities capabilities = 4;
uint64 capabilities = 4;

// The current health of the Agent.
// May be omitted if nothing changed since last AgentToServer message.
Expand Down Expand Up @@ -74,7 +74,7 @@ message AgentToServer {
AgentDisconnect agent_disconnect = 9;

// Bit flags as defined by AgentToServerFlags bit masks.
AgentToServerFlags flags = 10;
uint64 flags = 10;
}

enum AgentToServerFlags {
Expand Down Expand Up @@ -118,8 +118,8 @@ message ServerToAgent {
// This field is set when the Server has packages to offer to the Agent.
PackagesAvailable packages_available = 5;

// Bit flags as defined by Flags bit masks.
ServerToAgentFlags flags = 6;
// Bit flags as defined by ServerToAgentFlags bit masks.
uint64 flags = 6;

// Bitmask of flags defined by ServerCapabilities enum.
// All bits that are not defined in ServerCapabilities enum MUST be set to 0
Expand All @@ -129,7 +129,7 @@ message ServerToAgent {
// This field MUST be set in the first ServerToAgent sent by the Server and MAY
// be omitted in subsequent ServerToAgent messages by setting it to
// UnspecifiedServerCapability value.
ServerCapabilities capabilities = 7;
uint64 capabilities = 7;

// Properties related to identification of the Agent, which can be overridden
// by the Server if needed.
Expand Down
Loading