more COBOL

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-01 00:58:12 -05:00
parent 706dbbc533
commit adb44a864f
3 changed files with 7 additions and 38 deletions

View File

@ -5,7 +5,7 @@
# go install # go install
all: droplet.pb.go hypervisor.pb.go cluster.pb.go event.pb.go experiments.pb.go all: droplet.pb.go hypervisor.pb.go event.pb.go experiments.pb.go
make -C example make -C example
vet: lint vet: lint
@ -54,14 +54,6 @@ experiments.pb.go: experiments.proto
--go_opt=Mexperiments.proto=go.wit.com/lib/protobuf/virtbuf \ --go_opt=Mexperiments.proto=go.wit.com/lib/protobuf/virtbuf \
experiments.proto experiments.proto
cluster.pb.go: cluster.proto
cd ~/go/src && protoc --go_out=. --proto_path=go.wit.com/lib/protobuf/virtbuf \
--go_opt=Mdroplet.proto=go.wit.com/lib/protobuf/virtbuf \
--go_opt=Mcluster.proto=go.wit.com/lib/protobuf/virtbuf \
--go_opt=Mhypervisor.proto=go.wit.com/lib/protobuf/virtbuf \
--go_opt=Mevent.proto=go.wit.com/lib/protobuf/virtbuf \
cluster.proto
deps: deps:
apt install golang-goprotobuf-dev apt install golang-goprotobuf-dev
apt install protobuf-compiler apt install protobuf-compiler

View File

@ -1,23 +0,0 @@
syntax = "proto3";
package virtbuf;
import "droplet.proto";
import "hypervisor.proto";
import "event.proto";
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
import "google/protobuf/duration.proto"; // Import the well-known type for Timestamp
message OldCluster {
int64 id = 1;
repeated string dirs = 2;
repeated Droplet droplets = 3;
repeated Hypervisor hypervisors = 4;
// repeated Event events = 5;
// Droplets d = 6;
Hypervisors h = 7;
Events e = 8;
google.protobuf.Timestamp unstable = 9; // the last time we heard anything from this droplet
google.protobuf.Duration unstable_timeout = 10; // the last time we heard anything from this droplet
}

View File

@ -116,14 +116,14 @@ func (d *Droplet) SprintHeader() string {
switch d.Current.State { switch d.Current.State {
case DropletState_ON: case DropletState_ON:
dur := time.Since(d.Current.OnSince.AsTime()) // time since 'ON' dur := time.Since(d.Current.OnSince.AsTime()) // time since 'ON'
header += " (on :" + FormatDuration(dur) + ")" header += fmt.Sprintf(" (on :%3s)", FormatDuration(dur))
case DropletState_OFF: case DropletState_OFF:
// everything is as it should be with this vm // everything is as it should be with this vm
dur := time.Since(d.Current.OffSince.AsTime()) // time since 'OFF' dur := time.Since(d.Current.OffSince.AsTime()) // time since 'OFF'
header += " (off:" + FormatDuration(dur) + ")" header += fmt.Sprintf(" (off:%3s)", FormatDuration(dur))
default: default:
dur := time.Since(d.Current.OffSince.AsTime()) // use 'OFF' here? dur := time.Since(d.Current.OffSince.AsTime()) // use 'OFF' here?
header += " (???:" + FormatDuration(dur) + ")" header += fmt.Sprintf(" (?? :%3s)", FormatDuration(dur))
} }
return header return header
} }
@ -144,14 +144,14 @@ func (d *Droplet) SprintDumpHeader() string {
switch d.Current.State { switch d.Current.State {
case DropletState_ON: case DropletState_ON:
dur := time.Since(d.Current.OnSince.AsTime()) // time since 'ON' dur := time.Since(d.Current.OnSince.AsTime()) // time since 'ON'
header += " (on :" + FormatDuration(dur) + ")" header += fmt.Sprintf(" (on :%3s)", FormatDuration(dur))
case DropletState_OFF: case DropletState_OFF:
// everything is as it should be with this vm // everything is as it should be with this vm
dur := time.Since(d.Current.OffSince.AsTime()) // time since 'OFF' dur := time.Since(d.Current.OffSince.AsTime()) // time since 'OFF'
header += " (off:" + FormatDuration(dur) + ")" header += fmt.Sprintf(" (off:%3s)", FormatDuration(dur))
default: default:
dur := time.Since(d.Current.OffSince.AsTime()) // use 'OFF' here? dur := time.Since(d.Current.OffSince.AsTime()) // use 'OFF' here?
header += " (???:" + FormatDuration(dur) + ")" header += fmt.Sprintf(" (?? :%3s)", FormatDuration(dur))
} }
return header return header
} }