Documentation
¶
Index ¶
- Constants
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomNumber() int
- func GenerateRandomString(n int) (string, error)
- func RandInt(min, max int) int
- type AcceptFunc
- type BroadCastFunc
- type Broadcaster
- type CommonData
- type Error
- type Future
- type NatsProtoo
- func (np *NatsProtoo) Close()
- func (np *NatsProtoo) NewBroadcaster(channel string) *Broadcaster
- func (np *NatsProtoo) NewRequestor(channel string) *Requestor
- func (np *NatsProtoo) OnBroadcast(channel string, listener BroadCastFunc)
- func (np *NatsProtoo) OnRequest(channel string, listener RequestFunc)
- func (np *NatsProtoo) Reply(message []byte, reply string) error
- func (np *NatsProtoo) Send(message []byte, subj string, reply string) error
- type Notification
- type NotificationData
- type PeerMsg
- type RawMessage
- type RejectFunc
- type Request
- type RequestData
- type RequestFunc
- type Requestor
- func (req *Requestor) AsyncRequest(method string, data interface{}) *Future
- func (req *Requestor) Request(method string, data interface{}, success AcceptFunc, reject RejectFunc)
- func (req *Requestor) SetRequestTimeout(d time.Duration)
- func (req *Requestor) SyncRequest(method string, data interface{}) (RawMessage, *Error)
- type RespondFunc
- type Response
- type ResponseData
- type ResponseErrData
- type ResponseError
- type Transcation
Constants ¶
View Source
const (
DefaultNatsURL = "nats://127.0.0.1:4222"
)
View Source
const ( // DefaultRequestTimeout . DefaultRequestTimeout = 15 * time.Second )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Broadcaster ¶
Broadcaster .
type CommonData ¶
type CommonData struct { ID int `json:"id"` Method string `json:"method"` Data RawMessage `json:"data"` }
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future .
func (*Future) Then ¶
func (future *Future) Then(resolve func(result RawMessage), reject func(err *Error))
Then .
type NatsProtoo ¶
NatsProtoo .
func (*NatsProtoo) NewBroadcaster ¶
func (np *NatsProtoo) NewBroadcaster(channel string) *Broadcaster
func (*NatsProtoo) NewRequestor ¶
func (np *NatsProtoo) NewRequestor(channel string) *Requestor
func (*NatsProtoo) OnBroadcast ¶
func (np *NatsProtoo) OnBroadcast(channel string, listener BroadCastFunc)
func (*NatsProtoo) OnRequest ¶
func (np *NatsProtoo) OnRequest(channel string, listener RequestFunc)
type Notification ¶
type Notification struct { CommonData NotificationData }
* Notification
{ notification : true, method : 'chatmessage', data : { foo : 'bar' } }
type NotificationData ¶
type NotificationData struct {
Notification bool `json:"notification"`
}
type PeerMsg ¶
type PeerMsg struct { RequestData ResponseData NotificationData CommonData }
func (PeerMsg) ToNotification ¶
func (m PeerMsg) ToNotification() Notification
type RawMessage ¶
type RawMessage []byte
func (RawMessage) MarshalJSON ¶
func (m RawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (RawMessage) Unmarshal ¶
func (r RawMessage) Unmarshal(msgType interface{}) *Error
func (*RawMessage) UnmarshalJSON ¶
func (m *RawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
type Request ¶
type Request struct { RequestData CommonData }
* Request
{ request : true, id : 12345678, method : 'chatmessage', data : { type : 'text', value : 'Hi there!' } }
type RequestData ¶
type RequestFunc ¶
type RequestFunc func(request Request, accept RespondFunc, reject RejectFunc)
RequestFunc .
type Requestor ¶
Requestor .
func (*Requestor) AsyncRequest ¶
AsyncRequest .
func (*Requestor) Request ¶
func (req *Requestor) Request(method string, data interface{}, success AcceptFunc, reject RejectFunc)
Request .
func (*Requestor) SetRequestTimeout ¶
SetRequestTimeout .
func (*Requestor) SyncRequest ¶
func (req *Requestor) SyncRequest(method string, data interface{}) (RawMessage, *Error)
SyncRequest .
type RespondFunc ¶
type RespondFunc func(data interface{})
type Response ¶
type Response struct { ResponseData CommonData }
* Success response
{ response : true, id : 12345678, ok : true, data : { foo : 'lalala' } }
func NewResponse ¶
type ResponseData ¶
type ResponseData struct { Response bool `json:"response"` Ok bool `json:"ok"` ResponseErrData }
type ResponseErrData ¶
type ResponseError ¶
type ResponseError struct { ResponseData CommonData }
* Error response
{ response : true, id : 12345678, ok : false, errorCode : 123, errorReason : 'Something failed' }
type Transcation ¶
type Transcation struct {
// contains filtered or unexported fields
}
Transcation .
Source Files
¶
Click to show internal directories.
Click to hide internal directories.