Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleRequest ¶
HandleRequest unmarshals a request byte array and dispatches the request to the requester
Types ¶
type AddEvent ¶
AddEvent represents a RES-client collection add event https://github.com/resgateio/resgate/blob/master/docs/res-client-protocol.md#collection-add-event
type ChangeEvent ¶
type ChangeEvent struct {
Values interface{} `json:"values"`
*Resources
}
ChangeEvent represents a RES-client model change event https://github.com/resgateio/resgate/blob/master/docs/res-client-protocol.md#model-change-event
type ErrorResponse ¶
ErrorResponse represents a JSON-RPC error response
type Event ¶
type Event struct {
Event string `json:"event"`
Data interface{} `json:"data,omitempty"`
}
Event represent a RES-client event object https://github.com/resgateio/resgate/blob/master/docs/res-client-protocol.md#event-object
type Request ¶
type Request struct {
Method string `json:"method"`
Params json.RawMessage `json:"params"`
ID *uint64 `json:"id"`
}
Request represent a RES-client request https://github.com/resgateio/resgate/blob/master/docs/res-client-protocol.md#requests
func (*Request) ErrorResponse ¶
ErrorResponse encodes an error to a request response
func (*Request) SuccessResponse ¶
SuccessResponse encodes a result to a request response
type Requester ¶
type Requester interface {
Send(data []byte)
GetResource(rid string, callback func(data *Resources, err error))
SubscribeResource(rid string, callback func(data *Resources, err error))
UnsubscribeResource(rid string, callback func(ok bool))
CallResource(rid, action string, params interface{}, callback func(result json.RawMessage, err error))
AuthResource(rid, action string, params interface{}, callback func(result json.RawMessage, err error))
NewResource(rid string, params interface{}, callback func(data *NewResult, err error))
}
Requester has the methods required to perform a rpc request
type Resources ¶
type Resources struct {
Models map[string]interface{} `json:"models,omitempty"`
Collections map[string]interface{} `json:"collections,omitempty"`
Errors map[string]*reserr.Error `json:"errors,omitempty"`
}
Resources holds a resource information to be sent to the client
type Response ¶
type Response struct {
Result interface{} `json:"result,omitempty"`
ID *uint64 `json:"id"`
}
Response represents a RES-client response
type UnsubscribeEvent ¶
UnsubscribeEvent represents a RES-client unsubscribe event https://github.com/resgateio/resgate/blob/master/docs/res-client-protocol.md#unsubscribe-event