Beispiel #1
0
func (gr SetResult) encode(root *protocol.Result, s *capnp.Segment) error {
	r, err := protocol.NewResult_SetResult(s)
	if err != nil {
		return err
	}

	root.SubResult().SetSet(r)
	return nil
}
Beispiel #2
0
func (hr HandshakeResult) encode(root *protocol.Result, s *capnp.Segment) error {
	r, err := protocol.NewResult_HandshakeResult(s)
	if err != nil {
		return err
	}
	r.SetClientId(hr.ClientId)

	root.SubResult().SetHandshake(r)
	return nil
}
Beispiel #3
0
func (gr GetResult) encode(root *protocol.Result, s *capnp.Segment) error {
	r, err := protocol.NewResult_GetResult(s)
	if err != nil {
		return err
	}
	r.SetKey(gr.Key)
	r.SetValue(gr.Value)
	r.SetExpiry(gr.Expiry)

	root.SubResult().SetGet(r)
	return nil
}
Beispiel #4
0
func (rs *Result) decodeHandshakeResult(msg protocol.Result) error {
	sub, err := msg.SubResult().Handshake()
	if err != nil {
		return err
	}

	clientId, err := sub.ClientId()
	if err != nil {
		return err
	}

	rs.SubResult = NewHandshakeResult(clientId)
	rs.Action = rs.SubResult.getAction()

	return nil
}
Beispiel #5
0
func (rs *Result) decodeGetResult(msg protocol.Result) error {
	sub, err := msg.SubResult().Get()
	if err != nil {
		return err
	}

	key, err := sub.Key()
	if err != nil {
		return err
	}

	value, err := sub.Value()
	if err != nil {
		return err
	}

	expiry := sub.Expiry()

	rs.SubResult = NewGetResult(key, value, expiry)
	rs.Action = rs.SubResult.getAction()

	return nil
}