Documentation
¶
Overview ¶
Package long_polling provides long polling client and server implementations.
Package long_polling provides long polling client and server implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Publish ¶
func Publish(url string, timeout time.Duration, header map[string][]string, publishRequest PublishRequest, username, password string, transport *net_http.Transport) (http.Response, error)
Publish is publish an event.
ex) response, err := long_polling.Publish("http://127.0.0.1:10000/publish", 10, nil, request, "", "", nil)
Types ¶
type FilePersistorInfo ¶
type FilePersistorInfo struct { Use bool FileName string WriteBufferSize int WriteFlushPeriodSeconds int }
FilePersistorInfo is file persistor information.
type PublishRequest ¶
PublishRequest is publish request information.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a struct that provides server related methods.
func (*Server) Start ¶
func (this *Server) Start(serverInfo ServerInfo, filePersistorInfo FilePersistorInfo, listenAndServeFailureFunc func(err error)) error
Start is start the server.
ex) err := server.Start(ServerInfo{...}, FilePersistorInfo{...}, nil)
type ServerInfo ¶
type ServerInfo struct { Address string TimeoutSeconds int SubscriptionURI string HandlerToRunBeforeSubscription func(w net_http.ResponseWriter, r *net_http.Request) bool PublishURI string HandlerToRunBeforePublish func(w net_http.ResponseWriter, r *net_http.Request) bool }
ServerInfo is server information.
type SubscriptionRequest ¶
type SubscriptionRequest struct { Category string `url:"category"` TimeoutSeconds int `url:"timeout"` SinceTime int64 `url:"since_time,omitempty"` LastID string `url:"last_id,omitempty"` }
SubscriptionRequest is subscription request information.
type SubscriptionResponse ¶
type SubscriptionResponse struct { Header net_http.Header StatusCode int Events []struct { Timestamp int64 `json:"timestamp"` Category string `json:"category"` ID string `json:"id"` Data string `json:"data"` } `json:"events"` }
SubscriptionResponse is subscription response information.
func Subscription ¶
func Subscription(url string, header map[string][]string, request SubscriptionRequest, username, password string, transport *net_http.Transport) (SubscriptionResponse, error)
Subscription is subscribes to event.
ex) response, err := long_polling.Subscription("http://127.0.0.1:10000/subscription", nil, request, "", "", nil)