func (e DataEvent) EventType() EventType {
	return DataEventType
}
EventType is the implementation of Event for ErrorResponse
package core
import (
	"encoding/json"
	"fmt"
	"github.com/oasislabs/oasis-gateway/errors"
	mqueue "github.com/oasislabs/oasis-gateway/mqueue/core"
	"github.com/oasislabs/oasis-gateway/rpc"
)
type Event interface {
	EventID() uint64
	EventType() EventType
}
type Events struct {
	Offset uint64
	Events []Event
}
type EventType string
const (
	DeployServiceEventType  EventType = "deployServiceEventType"
	ExecuteServiceEventType EventType = "executeServiceEventType"
	ErrorEventType          EventType = "errorEventType"
	DataEventType           EventType = "dataEventType"
)
func (t EventType) String() string {
	return string(t)
}
func makeElement(ev Event, offset uint64) (mqueue.Element, error) {
	p, err := json.Marshal(ev)
	if err != nil {
		return mqueue.Element{}, err
	}
	return mqueue.Element{
		Offset: offset,
		Type:   ev.EventType().String(),
		Value:  string(p),
	}, nil
}
func deserializeElement(el mqueue.Element) (Event, errors.Err) {
	switch EventType(el.Type) {
	case DeployServiceEventType:
		var ev DeployServiceResponse
		if err := json.Unmarshal([]byte(el.Value), &ev); err != nil {
			return nil, errors.New(errors.ErrDeserializeEvent, err)
		}
		return ev, nil
	case ExecuteServiceEventType:
		var ev ExecuteServiceResponse
		if err := json.Unmarshal([]byte(el.Value), &ev); err != nil {
			return nil, errors.New(errors.ErrDeserializeEvent, err)
		}
		return ev, nil
	case ErrorEventType:
		var ev ErrorEvent
		if err := json.Unmarshal([]byte(el.Value), &ev); err != nil {
			return nil, errors.New(errors.ErrDeserializeEvent, err)
		}
		return ev, nil
	case DataEventType:
		var ev DataEvent
		if err := json.Unmarshal([]byte(el.Value), &ev); err != nil {
			return nil, errors.New(errors.ErrDeserializeEvent, err)
		}
		return ev, nil
	default:
		return nil, errors.New(errors.ErrUnkownEventType, nil)
	}
}
func SubID(key string, id uint64) string {
	return fmt.Sprintf("%s:sub:%d", key, id)
}
func SubinfoID(key string) string {
	return fmt.Sprintf("%s:subinfo", key)
}
type ExecuteServiceRequest struct {
	AAD string
	Data string
	Address string
	SessionKey string
}
type DeployServiceRequest struct {
	AAD string
	Data string
	SessionKey string
}
type GetCodeRequest struct {
	Address string `json:"address"`
}
type GetCodeResponse struct {
	Address string
	Code string
}
type GetExpiryRequest struct {
	Address string `json:"address"`
}
type GetExpiryResponse struct {
	Address string
	Expiry uint64
}
type GetPublicKeyRequest struct {
	Address string `json:"address"`
}
type GetPublicKeyResponse struct {
	Timestamp uint64
	Address string
	PublicKey string
	Signature string
}
type ErrorEvent struct {
	ID uint64
	Cause rpc.Error
}
type ExecuteServiceResponse struct {
	ID uint64
	Address string
	Output string
}
type DeployServiceResponse struct {
	ID uint64
	Address string
}
type DataEvent struct {
	ID uint64
	Data string
	Topics []string
}
func (e ExecuteServiceResponse) EventID() uint64 {
	return e.ID
}
func (e ExecuteServiceResponse) EventType() EventType {
	return ExecuteServiceEventType
}
func (e DeployServiceResponse) EventID() uint64 {
	return e.ID
}
func (e DeployServiceResponse) EventType() EventType {
	return DeployServiceEventType
}
func (e ErrorEvent) EventID() uint64 {
	return e.ID
}
func (e ErrorEvent) EventType() EventType {
	return ErrorEventType
}
func (e DataEvent) EventID() uint64 {
	return e.ID
}