diff --git a/cmd/cgat/main.go b/cmd/cgat/main.go index 41d3b07323ab10f6bc386b9977f8b116fde4f270..2bee445e4e0b5766430bbbd7ded2624e0476d49b 100644 --- a/cmd/cgat/main.go +++ b/cmd/cgat/main.go @@ -1,7 +1,6 @@ package main import ( - "io" "net" "net/http" _ "net/http/pprof" @@ -9,67 +8,10 @@ import ( "pggat2/lib/backend/backends/v0" "pggat2/lib/frontend/frontends/v0" "pggat2/lib/pnet" - "pggat2/lib/pnet/packet" "pggat2/lib/rob" "pggat2/lib/rob/schedulers/v2" ) -type testPacket struct { - typ packet.Type - bytes []byte -} - -type TestReader struct { - packets []testPacket - idx int - buf packet.InBuf -} - -func (T *TestReader) Read() (packet.In, error) { - if T.idx >= len(T.packets) { - return packet.In{}, io.EOF - } - pkt := T.packets[T.idx] - T.idx++ - if pkt.typ == packet.None { - panic("expected typed packet") - } - T.buf.Reset(pkt.typ, pkt.bytes) - return packet.MakeIn(&T.buf), nil -} - -func (T *TestReader) ReadUntyped() (packet.In, error) { - if T.idx >= len(T.packets) { - return packet.In{}, io.EOF - } - pkt := T.packets[T.idx] - T.idx++ - if pkt.typ != packet.None { - panic("expected untyped packet") - } - T.buf.Reset(pkt.typ, pkt.bytes) - return packet.MakeIn(&T.buf), nil -} - -var _ pnet.Reader = (*TestReader)(nil) - -type LogWriter struct { - buf packet.OutBuf -} - -func (T *LogWriter) Write() packet.Out { - if !T.buf.Initialized() { - T.buf.Initialize(func(t packet.Type, bytes []byte) error { - // log.Printf("recv %c %v\n", t, bytes) - return nil - }) - } - T.buf.Reset() - return packet.MakeOut(&T.buf) -} - -var _ pnet.Writer = (*LogWriter)(nil) - type job struct { rw pnet.ReadWriter done chan<- struct{}