Removed unecessary capnp dependency

gql_cataclysm
noah metz 2023-09-18 20:11:50 -06:00
parent ab5b922a7d
commit ff7046badf
6 changed files with 9 additions and 213 deletions

@ -1,9 +1,4 @@
.PHONY: schema test
.PHONY: test
test: schema
test:
clear && go test
schema: signal/signal.capnp.go
%.capnp.go: %.capnp
capnp compile -I ./go-capnp/std -ogo $<

@ -2,15 +2,11 @@ module github.com/mekkanized/graphvent
go 1.21.0
replace github.com/mekkanized/graphvent/signal v0.0.0 => ./signal
require (
capnproto.org/go/capnp/v3 v3.0.0-alpha-29
github.com/dgraph-io/badger/v3 v3.2103.5
github.com/gobwas/ws v1.2.1
github.com/google/uuid v1.3.0
github.com/graphql-go/graphql v0.8.1
github.com/mekkanized/graphvent/signal v0.0.0
github.com/rs/zerolog v1.29.1
golang.org/x/net v0.7.0
)
@ -32,8 +28,7 @@ require (
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/stretchr/testify v1.8.2 // indirect
go.opencensus.io v0.22.5 // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
golang.org/x/sys v0.6.0 // indirect
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5 // indirect
)

@ -1,5 +1,3 @@
capnproto.org/go/capnp/v3 v3.0.0-alpha-29 h1:ICLhiy4Jmp0d7hLQO+HzFAVIft/oxpPAUPV8tqx+eUE=
capnproto.org/go/capnp/v3 v3.0.0-alpha-29/go.mod h1:+ysMHvOh1EWNOyorxJWs1omhRFiDoKxKkWQACp54jKM=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
@ -72,8 +70,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -92,12 +88,14 @@ github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb6
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tinylib/msgp v1.1.5 h1:2gXmtWueD2HefZHQe1QOy9HVzmFrLOVvsXwXBQ0ayy0=
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@ -130,7 +128,6 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -165,8 +162,7 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5 h1:yksDCGMVzyn3vlyf0GZ3huiF5FFaMGQpQ3UJvR0EoGA=
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5/go.mod h1:1LtNdPAs8WH+BTcQiZAOo2MIKD/5jyK/u7sZ9ZPe5SE=

@ -4,9 +4,7 @@ import (
"fmt"
"time"
"capnproto.org/go/capnp/v3"
"github.com/google/uuid"
schema "github.com/mekkanized/graphvent/signal"
)
type SignalDirection uint8
@ -93,48 +91,6 @@ func NewRespHeader(req_id uuid.UUID, direction SignalDirection) SignalHeader {
return header
}
func SerializeHeader(header SignalHeader, root schema.SignalHeader) error {
root.SetDirection(uint8(header.Direction))
id_ser, err := header.ID.MarshalBinary()
if err != nil {
return err
}
root.SetId(id_ser)
req_id_ser, err := header.ReqID.MarshalBinary()
if err != nil {
return err
}
root.SetReqID(req_id_ser)
return nil
}
func DeserializeHeader(header schema.SignalHeader) (SignalHeader, error) {
id_ser, err := header.Id()
if err != nil {
return SignalHeader{}, err
}
id, err := uuid.FromBytes(id_ser)
if err != nil {
return SignalHeader{}, err
}
req_id_ser, err := header.ReqID()
if err != nil {
return SignalHeader{}, err
}
req_id, err := uuid.FromBytes(req_id_ser)
if err != nil {
return SignalHeader{}, err
}
return SignalHeader{
ID: id,
ReqID: req_id,
Direction: SignalDirection(header.Direction()),
}, nil
}
type CreateSignal struct {
SignalHeader
}
@ -195,59 +151,6 @@ type ErrorSignal struct {
func (signal ErrorSignal) Header() *SignalHeader {
return &signal.SignalHeader
}
func (signal ErrorSignal) MarshalBinary() ([]byte, error) {
arena := capnp.SingleSegment(nil)
msg, seg, err := capnp.NewMessage(arena)
if err != nil {
return nil, err
}
root, err := schema.NewRootErrorSignal(seg)
if err != nil {
return nil, err
}
root.SetError(signal.Error)
header, err := root.NewHeader()
if err != nil {
return nil, err
}
err = SerializeHeader(signal.SignalHeader, header)
if err != nil {
return nil, err
}
return msg.Marshal()
}
func (signal ErrorSignal) Deserialize(ctx *Context, data []byte) error {
msg, err := capnp.Unmarshal(data)
if err != nil {
return err
}
root, err := schema.ReadRootErrorSignal(msg)
if err != nil {
return err
}
header, err := root.Header()
if err != nil {
return err
}
signal.Error, err = root.Error()
if err != nil {
return err
}
signal.SignalHeader, err = DeserializeHeader(header)
if err != nil {
return err
}
return nil
}
func (signal ErrorSignal) Permission() Tree {
return Tree{
SerializedType(ErrorSignalType): nil,
@ -359,54 +262,6 @@ type ReadSignal struct {
SignalHeader
Extensions map[ExtType][]string `json:"extensions"`
}
func (signal ReadSignal) MarshalBinary() ([]byte, error) {
arena := capnp.SingleSegment(nil)
msg, seg, err := capnp.NewMessage(arena)
if err != nil {
return nil, err
}
root, err := schema.NewRootReadSignal(seg)
if err != nil {
return nil, err
}
header, err := root.NewHeader()
if err != nil {
return nil, err
}
err = SerializeHeader(signal.SignalHeader, header)
if err != nil {
return nil, err
}
extensions, err := root.NewExtensions(int32(len(signal.Extensions)))
if err != nil {
return nil, err
}
i := 0
for ext_type, fields := range(signal.Extensions) {
extension := extensions.At(i)
extension.SetType(uint64(ext_type))
f, err := extension.NewFields(int32(len(fields)))
if err != nil {
return nil, err
}
for j, field := range(fields) {
err := f.Set(j, field)
if err != nil {
return nil, err
}
}
i += 1
}
return msg.Marshal()
}
func (signal ReadSignal) Header() *SignalHeader {
return &signal.SignalHeader
}

@ -1,10 +0,0 @@
module github.com/mekkanized/graphvent/signal
go 1.21.0
require capnproto.org/go/capnp/v3 v3.0.0-alpha-29
require (
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5 // indirect
)

@ -1,35 +0,0 @@
using Go = import "/go.capnp";
@0x83a311a90429ef94;
$Go.package("signal");
$Go.import("github.com/mekkanized/graphvent/signal");
struct SignalHeader {
direction @0 :UInt8;
id @1 :Data;
reqID @2 :Data;
}
struct ErrorSignal {
header @0 :SignalHeader;
error @1 :Text;
}
struct LinkSignal {
header @0 :SignalHeader;
action @1 :Text;
id @2 :Data;
}
struct LockSignal {
header @0 :SignalHeader;
state @1 :Text;
}
struct ReadSignal {
header @0 :SignalHeader;
extensions @1 :List(Extension);
struct Extension {
type @0 :UInt64;
fields @1 :List(Text);
}
}