Documentation ¶
Index ¶
- type Arg
- type Channel
- type CompactTweetParser
- type Conn
- type Flock
- func (flock *Flock) Add(twitter TweetHandler, options TwitterOptions)
- func (flock *Flock) AddMany(twitters []TweetHandler, options TwitterOptions)
- func (flock *Flock) AddMiddleware(twitter TweetHandler, options MiddlewareOptions)
- func (flock *Flock) AddOnConnection(middleware OnConnectionHandler)
- func (flock *Flock) AddOnDisconnection(middleware OnDisconnectionHandler)
- func (flock *Flock) GePosttMiddlewares(scope Scope) []TweetHandler
- func (flock *Flock) Get(code string, scope Scope) (TweetHandler, bool)
- func (flock *Flock) GetMiddlewares(scope Scope) []TweetHandler
- type Middleware
- type MiddlewareOptions
- type NanoWebsocket
- type OnConnectionHandler
- type OnDisconnectionHandler
- type ReadWriteBuffer
- type Scope
- type Sparrow
- func (sparrow *Sparrow) Install(twitter Twitter)
- func (sparrow *Sparrow) InstallMiddleware(middleware Middleware, options MiddlewareOptions)
- func (sparrow *Sparrow) LogUserIn(id []byte, scope Scope, ws *Conn) bool
- func (sparrow *Sparrow) LogUserOut(id []byte, ws Conn) bool
- func (sparrow *Sparrow) OnConnection(middleware OnConnectionHandler)
- func (sparrow *Sparrow) OnDisconnection(middleware OnDisconnectionHandler)
- func (sparrow *Sparrow) Run()
- func (sparrow *Sparrow) Use(twitter TweetHandler, options TwitterOptions)
- func (sparrow *Sparrow) UseMiddleware(middleware TweetHandler, options MiddlewareOptions)
- type Tweet
- type TweetHandler
- type TweetParser
- type Twitter
- type TwitterOptions
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type CompactTweetParser ¶
type CompactTweetParser struct { }
CompactTweetParser parses tweets encoded using compact tweet format a compact tweet format is [code;arg1=arg1v,arg2=arg2v,argN=argNv;content] arguments and content are optional code, args, content must end with ;
func (*CompactTweetParser) Compile ¶
func (parser *CompactTweetParser) Compile(code, arguments string, content []byte) []byte
Compile creates a raw tweet out of twwet parts example: char *args[]{tweet.code, tweet.argument, tweet.content}
func (*CompactTweetParser) Parse ¶
func (parser *CompactTweetParser) Parse(message []byte) *Tweet
Parse parses a tweet text and returns a Tweet type
func (*CompactTweetParser) Serialize ¶
func (parser *CompactTweetParser) Serialize(tweet *Tweet) []byte
Serialize serializes a tweet into a string different than raw, as the tweet may have been changed so, this function re-constructs the tweet's string
type Conn ¶
func (*Conn) WriteMessage ¶
type Flock ¶
type Flock struct { OnConnectionMiddlewares []OnConnectionHandler OnDisconnectionMiddlewares []OnDisconnectionHandler // contains filtered or unexported fields }
func (*Flock) Add ¶
func (flock *Flock) Add(twitter TweetHandler, options TwitterOptions)
tiwtter callbacks. These are the actual callbacks that will process tweets they're not middlewares
func (*Flock) AddMany ¶
func (flock *Flock) AddMany(twitters []TweetHandler, options TwitterOptions)
func (*Flock) AddMiddleware ¶
func (flock *Flock) AddMiddleware(twitter TweetHandler, options MiddlewareOptions)
middlewares
func (*Flock) AddOnConnection ¶
func (flock *Flock) AddOnConnection(middleware OnConnectionHandler)
install a single middleware to be run when a new ws is connected
func (*Flock) AddOnDisconnection ¶
func (flock *Flock) AddOnDisconnection(middleware OnDisconnectionHandler)
install a single middleware to be run when a ws is disconnected
func (*Flock) GePosttMiddlewares ¶
func (flock *Flock) GePosttMiddlewares(scope Scope) []TweetHandler
middlewares with Scope.Any should be returned here, even if scope was diffferent
func (*Flock) Get ¶
func (flock *Flock) Get(code string, scope Scope) (TweetHandler, bool)
retrieve a twitter
func (*Flock) GetMiddlewares ¶
func (flock *Flock) GetMiddlewares(scope Scope) []TweetHandler
middlewares with Scope.Any should be returned here, even if scope was diffferent
type Middleware ¶
type Middleware interface { // register middleware Congregate(flock *Flock, options MiddlewareOptions) }
Middleware sparrow middlewares should implement this interface
type MiddlewareOptions ¶
MiddlewareOptions can be used to change a middleware's scope or run it before/after twitter
type NanoWebsocket ¶
type NanoWebsocket struct { OnOpen func(c *Conn, handshake *ws.Handshake) OnClose func(c *Conn, err error) (action evio.Action) OnMessage func(c *Conn, mesaage wsutil.Message) (out []byte, action evio.Action) OnPing func(c *Conn) OnPong func(c *Conn) }
func (*NanoWebsocket) Serve ¶
func (nano *NanoWebsocket) Serve(addr ...string) error
type OnConnectionHandler ¶
type OnDisconnectionHandler ¶
type ReadWriteBuffer ¶
type ReadWriteBuffer struct {
// contains filtered or unexported fields
}
type Sparrow ¶
type Sparrow struct { // contains twitters, followers, leaders, middlewares, and postwares Flock Flock TweetParser TweetParser Users *trie.PathTrie Channels *trie.PathTrie }
Sparrow server
func (*Sparrow) InstallMiddleware ¶
func (sparrow *Sparrow) InstallMiddleware(middleware Middleware, options MiddlewareOptions)
middleware run order: 1- middlewares 2- twitter-specific middlewares 3- twitter 4- post middlewares 5- twitter-specific post middlewares
func (*Sparrow) OnConnection ¶
func (sparrow *Sparrow) OnConnection(middleware OnConnectionHandler)
install a single middleware to be run when a new ws is connected
func (*Sparrow) OnDisconnection ¶
func (sparrow *Sparrow) OnDisconnection(middleware OnDisconnectionHandler)
install a single middleware to be run when a ws is disconnected
func (*Sparrow) Use ¶
func (sparrow *Sparrow) Use(twitter TweetHandler, options TwitterOptions)
func (*Sparrow) UseMiddleware ¶
func (sparrow *Sparrow) UseMiddleware(middleware TweetHandler, options MiddlewareOptions)
callback middlewares (lambda instead of classes)
type Tweet ¶
type TweetHandler ¶
Conn, user, tweet, twitter, success: the result of the ran twitter, for post middlewares
type TweetParser ¶
TweetParser an interface for twwet parsers