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 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 RejectFunc
- type Request
- type RequestFunc
- type Requestor
- func (req *Requestor) AsyncRequest(method string, data map[string]interface{}) *Future
- func (req *Requestor) Request(method string, data map[string]interface{}, success AcceptFunc, ...)
- func (req *Requestor) SetRequestTimeout(d time.Duration)
- func (req *Requestor) SyncRequest(method string, data map[string]interface{}) (map[string]interface{}, *Error)
- type Response
- 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 BroadCastFunc ¶
BroadCastFunc .
type Broadcaster ¶
Broadcaster .
func (*Broadcaster) Say ¶
func (bc *Broadcaster) Say(method string, data map[string]interface{})
Say .
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 { Notification bool `json:"notification"` Method string `json:"method"` Data map[string]interface{} `json:"data"` }
* Notification
{ notification : true, method : 'chatmessage', data : { foo : 'bar' } }
type Request ¶
type Request struct { Request bool `json:"request"` ID int `json:"id"` ReplySubj string `json:"reply"` Method string `json:"method"` Data map[string]interface{} `json:"data"` }
* Request
{ request : true, id : 12345678, method : 'chatmessage', data : { type : 'text', value : 'Hi there!' } }
type RequestFunc ¶
type RequestFunc func(request map[string]interface{}, accept AcceptFunc, reject RejectFunc)
RequestFunc .
type Requestor ¶
Requestor .
func (*Requestor) AsyncRequest ¶
AsyncRequest .
func (*Requestor) Request ¶
func (req *Requestor) Request(method string, data map[string]interface{}, success AcceptFunc, reject RejectFunc)
Request .
func (*Requestor) SetRequestTimeout ¶
SetRequestTimeout .
type Response ¶
type Response struct { Response bool `json:"response"` ID int `json:"id"` Ok bool `json:"ok"` Data map[string]interface{} `json:"data"` }
* Success response
{ response : true, id : 12345678, ok : true, data : { foo : 'lalala' } }
type ResponseError ¶
type ResponseError struct { Response bool `json:"response"` ID int `json:"id"` Ok bool `json:"ok"` ErrorCode int `json:"errorCode"` ErrorReason string `json:"errorReason"` }
* 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.