From 2bdabeb4287b2a0e39f23eafb5c50c45b0f18f59 Mon Sep 17 00:00:00 2001 From: Manish R Jain <manishrjain@gmail.com> Date: Mon, 29 Feb 2016 09:41:44 +1100 Subject: [PATCH] Forgot to add mutation encoding, decoding code. --- worker/mutation.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 worker/mutation.go diff --git a/worker/mutation.go b/worker/mutation.go new file mode 100644 index 00000000..01a9b713 --- /dev/null +++ b/worker/mutation.go @@ -0,0 +1,26 @@ +package worker + +import ( + "bytes" + "encoding/gob" + + "github.com/dgraph-io/dgraph/x" +) + +type Mutations struct { + Set []x.DirectedEdge + Del []x.DirectedEdge +} + +func (m *Mutations) Encode() (data []byte, rerr error) { + var b bytes.Buffer + enc := gob.NewEncoder(&b) + rerr = enc.Encode(*m) + return b.Bytes(), rerr +} + +func (m *Mutations) Decode(data []byte) error { + r := bytes.NewReader(data) + dec := gob.NewDecoder(r) + return dec.Decode(m) +} -- GitLab