Skip to content

Commit

Permalink
[core] Send ODC device IDs as string for JS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Jun 4, 2024
1 parent 16e68f9 commit f4fed12
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions core/integration/odc/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,21 @@ type OdcStatus struct {
Error *odc.Error
}

type OdcDeviceId uint64

func (o OdcDeviceId) MarshalJSON() ([]byte, error) {
return json.Marshal(strconv.FormatUint(uint64(o), 10))
}

type OdcPartitionInfo struct {
PartitionId uid.ID `json:"-"`
RunNumber uint32 `json:"runNumber"`
State string `json:"state"`
EcsState sm.State `json:"ecsState"`
DdsSessionId string `json:"ddsSessionId"`
DdsSessionStatus string `json:"ddsSessionStatus"`
Devices map[uint64]OdcDevice `json:"devices"`
Hosts []string `json:"hosts"`
PartitionId uid.ID `json:"-"`
RunNumber uint32 `json:"runNumber"`
State string `json:"state"`
EcsState sm.State `json:"ecsState"`
DdsSessionId string `json:"ddsSessionId"`
DdsSessionStatus string `json:"ddsSessionStatus"`
Devices map[OdcDeviceId]OdcDevice `json:"devices"`
Hosts []string `json:"hosts"`
}

type OdcDevice struct {
Expand Down Expand Up @@ -248,9 +254,9 @@ func (p *Plugin) queryPartitionStatus() {
}

odcPartInfoSlice[idx].Hosts = odcPartStateRep.Reply.Hosts
odcPartInfoSlice[idx].Devices = make(map[uint64]OdcDevice, len(odcPartStateRep.Devices))
odcPartInfoSlice[idx].Devices = make(map[OdcDeviceId]OdcDevice, len(odcPartStateRep.Devices))
for _, device := range odcPartStateRep.Devices {
odcPartInfoSlice[idx].Devices[device.Id] = OdcDevice{
odcPartInfoSlice[idx].Devices[OdcDeviceId(device.Id)] = OdcDevice{
TaskId: strconv.FormatUint(device.Id, 10),
State: device.State,
Path: device.Path,
Expand Down

0 comments on commit f4fed12

Please sign in to comment.