Skip to content

Commit

Permalink
First pass at protobuffing fully custom with SchedulingInput
Browse files Browse the repository at this point in the history
  • Loading branch information
LPetro committed Aug 7, 2024
1 parent 1c3ce9e commit bcbc362
Show file tree
Hide file tree
Showing 8 changed files with 901 additions and 300 deletions.
34 changes: 17 additions & 17 deletions pkg/controllers/orb/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *Controller) Reconcile(ctx context.Context) (reconcile.Result, error) {

// Pop each scheduling input off my heap (oldest first) and batch log in PV
for c.schedulingInputHeap.Len() > 0 {
currentInput := c.schedulingInputHeap.Pop().(SchedulingInput) // Min heap, so always pops the oldest
currentInput := c.schedulingInputHeap.Pop().(SchedulingInput)

inputDiffAdded := &SchedulingInput{}
inputDiffRemoved := &SchedulingInput{}
Expand Down Expand Up @@ -141,14 +141,14 @@ func (c *Controller) Register(_ context.Context, m manager.Manager) error {
func (c *Controller) SaveToPV(item SchedulingInput, difftype string) error {

//fmt.Println("Saving Scheduling Input to PV:\n", item.String()) // Test print
// logdata, err := item.Marshal()
// if err != nil {
// fmt.Println("Error converting Scheduling Input to Protobuf:", err)
// return err
// }
logdata, err := item.Marshal()
if err != nil {
fmt.Println("Error converting Scheduling Input to Protobuf:", err)
return err
}

// TODO: Instead of the above, In the interim while I figure out the custom protobuf... Just send string to file
logdata := item.String()
// // TODO: Instead of the above, In the interim while I figure out the custom protobuf... Just send string to file
// logdata := item.String()

timestampStr := item.Timestamp.Format("2006-01-02_15-04-05Z")
fileName := fmt.Sprintf("SchedulingInput_%s_%s.log", difftype, timestampStr)
Expand All @@ -162,20 +162,20 @@ func (c *Controller) SaveToPV(item SchedulingInput, difftype string) error {
}
defer file.Close()

// // Writes serialized data to the file
// _, err = file.Write(logdata)
// if err != nil {
// fmt.Println("Error writing data to file:", err)
// return err
// }

// TODO: Uncomment above; Testing Version // only here while testing string print
_, err = fmt.Fprintln(file, logdata)
// Writes serialized data to the file
_, err = file.Write(logdata)
if err != nil {
fmt.Println("Error writing data to file:", err)
return err
}

// // TODO: Uncomment above; Testing Version // only here while testing string print
// _, err = fmt.Fprintln(file, logdata)
// if err != nil {
// fmt.Println("Error writing data to file:", err)
// return err
// }

fmt.Printf("%s data written to S3 bucket successfully!\n", difftype)
return nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/orb/heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (h SchedulingInputHeap) Len() int {
return len(h)
}

// This compares timestamps for a min heap, so that older inputs pop first.
func (h SchedulingInputHeap) Less(i, j int) bool {
return h[i].Timestamp.Before(h[j].Timestamp)
}
Expand Down
154 changes: 0 additions & 154 deletions pkg/controllers/orb/proto/ORBLogEntry.pb.go

This file was deleted.

51 changes: 0 additions & 51 deletions pkg/controllers/orb/proto/ORBLogEntry.proto

This file was deleted.

Loading

0 comments on commit bcbc362

Please sign in to comment.