Documentation ¶
Index ¶
- Constants
- Variables
- func GetTypeFromStructDeclaration(o interface{}) reflect.Type
- func JsonBytes(res interface{}) (bytez []byte, err error)
- func SocketType(listenAddr string) string
- func WriteTo(bz []byte, w io.Writer, n *int) (err error)
- type Options
- type RPCRequest
- type RPCResponse
- type Result
- type StructFieldInfo
- type TypeInfo
- type WSRPCConnection
- type WSRPCContext
Constants ¶
View Source
const (
Iso8601 = "2006-01-02T15:04:05.000Z" // forced microseconds
)
Variables ¶
View Source
var (
TimeType = GetTypeFromStructDeclaration(struct{ time.Time }{})
)
Functions ¶
func SocketType ¶
---------------------------------------- sockets
Determine if its a unix or tcp socket. If tcp, must specify the port; `0.0.0.0` will return incorrectly as "unix" since there's no port
Types ¶
type Options ¶
type Options struct { JSONName string // (JSON) Corresponding JSON field name. (override with `json=""`) JSONOmitEmpty bool // (JSON) Omit field if value is empty Varint bool // (Binary) Use length-prefixed encoding for (u)int64 Unsafe bool // (JSON/Binary) Explicitly enable support for floats or maps ZeroValue interface{} // Prototype zero object }
type RPCRequest ¶
type RPCRequest struct { JSONRPC string `json:"jsonrpc"` ID string `json:"id"` Method string `json:"method"` Params []interface{} `json:"params"` }
func NewRPCRequest ¶
func NewRPCRequest(id string, method string, params []interface{}) RPCRequest
type RPCResponse ¶
type RPCResponse struct { JSONRPC string `json:"jsonrpc"` ID string `json:"id"` Result *json.RawMessage `json:"result"` Error string `json:"error"` }
func NewRPCResponse ¶
func NewRPCResponse(id string, res interface{}, err string) RPCResponse
type StructFieldInfo ¶
type TypeInfo ¶
type TypeInfo struct { Type reflect.Type // The type // If Type is kind reflect.Interface, is registered IsRegisteredInterface bool ByteToType map[byte]reflect.Type TypeToByte map[reflect.Type]byte // If Type is kind reflect.Struct Fields []StructFieldInfo Unwrap bool // if struct has only one field and its an anonymous interface }
func GetTypeInfo ¶
func MakeTypeInfo ¶
type WSRPCConnection ¶
type WSRPCConnection interface { GetRemoteAddr() string GetEventSwitch() events.EventSwitch WriteRPCResponse(resp RPCResponse) TryWriteRPCResponse(resp RPCResponse) bool }
*wsConnection implements this interface.
type WSRPCContext ¶
type WSRPCContext struct { Request RPCRequest WSRPCConnection }
websocket-only RPCFuncs take this as the first parameter.
Click to show internal directories.
Click to hide internal directories.