id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
24,400
eclipse/paho.mqtt.golang
options.go
SetMaxReconnectInterval
func (o *ClientOptions) SetMaxReconnectInterval(t time.Duration) *ClientOptions { o.MaxReconnectInterval = t return o }
go
func (o *ClientOptions) SetMaxReconnectInterval(t time.Duration) *ClientOptions { o.MaxReconnectInterval = t return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetMaxReconnectInterval", "(", "t", "time", ".", "Duration", ")", "*", "ClientOptions", "{", "o", ".", "MaxReconnectInterval", "=", "t", "\n", "return", "o", "\n", "}" ]
// SetMaxReconnectInterval sets the maximum time that will be waited between reconnection attempts // when connection is lost
[ "SetMaxReconnectInterval", "sets", "the", "maximum", "time", "that", "will", "be", "waited", "between", "reconnection", "attempts", "when", "connection", "is", "lost" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L313-L316
24,401
eclipse/paho.mqtt.golang
options.go
SetAutoReconnect
func (o *ClientOptions) SetAutoReconnect(a bool) *ClientOptions { o.AutoReconnect = a return o }
go
func (o *ClientOptions) SetAutoReconnect(a bool) *ClientOptions { o.AutoReconnect = a return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetAutoReconnect", "(", "a", "bool", ")", "*", "ClientOptions", "{", "o", ".", "AutoReconnect", "=", "a", "\n", "return", "o", "\n", "}" ]
// SetAutoReconnect sets whether the automatic reconnection logic should be used // when the connection is lost, even if disabled the ConnectionLostHandler is still // called
[ "SetAutoReconnect", "sets", "whether", "the", "automatic", "reconnection", "logic", "should", "be", "used", "when", "the", "connection", "is", "lost", "even", "if", "disabled", "the", "ConnectionLostHandler", "is", "still", "called" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L321-L324
24,402
eclipse/paho.mqtt.golang
options.go
SetMessageChannelDepth
func (o *ClientOptions) SetMessageChannelDepth(s uint) *ClientOptions { o.MessageChannelDepth = s return o }
go
func (o *ClientOptions) SetMessageChannelDepth(s uint) *ClientOptions { o.MessageChannelDepth = s return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetMessageChannelDepth", "(", "s", "uint", ")", "*", "ClientOptions", "{", "o", ".", "MessageChannelDepth", "=", "s", "\n", "return", "o", "\n", "}" ]
// SetMessageChannelDepth sets the size of the internal queue that holds messages while the // client is temporairily offline, allowing the application to publish when the client is // reconnecting. This setting is only valid if AutoReconnect is set to true, it is otherwise // ignored.
[ "SetMessageChannelDepth", "sets", "the", "size", "of", "the", "internal", "queue", "that", "holds", "messages", "while", "the", "client", "is", "temporairily", "offline", "allowing", "the", "application", "to", "publish", "when", "the", "client", "is", "reconnecti...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L330-L333
24,403
eclipse/paho.mqtt.golang
options.go
SetHTTPHeaders
func (o *ClientOptions) SetHTTPHeaders(h http.Header) *ClientOptions { o.HTTPHeaders = h return o }
go
func (o *ClientOptions) SetHTTPHeaders(h http.Header) *ClientOptions { o.HTTPHeaders = h return o }
[ "func", "(", "o", "*", "ClientOptions", ")", "SetHTTPHeaders", "(", "h", "http", ".", "Header", ")", "*", "ClientOptions", "{", "o", ".", "HTTPHeaders", "=", "h", "\n", "return", "o", "\n", "}" ]
// SetHTTPHeaders sets the additional HTTP headers that will be sent in the WebSocket // opening handshake.
[ "SetHTTPHeaders", "sets", "the", "additional", "HTTP", "headers", "that", "will", "be", "sent", "in", "the", "WebSocket", "opening", "handshake", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options.go#L337-L340
24,404
eclipse/paho.mqtt.golang
token.go
WaitTimeout
func (b *baseToken) WaitTimeout(d time.Duration) bool { b.m.Lock() defer b.m.Unlock() timer := time.NewTimer(d) select { case <-b.complete: if !timer.Stop() { <-timer.C } return true case <-timer.C: } return false }
go
func (b *baseToken) WaitTimeout(d time.Duration) bool { b.m.Lock() defer b.m.Unlock() timer := time.NewTimer(d) select { case <-b.complete: if !timer.Stop() { <-timer.C } return true case <-timer.C: } return false }
[ "func", "(", "b", "*", "baseToken", ")", "WaitTimeout", "(", "d", "time", ".", "Duration", ")", "bool", "{", "b", ".", "m", ".", "Lock", "(", ")", "\n", "defer", "b", ".", "m", ".", "Unlock", "(", ")", "\n\n", "timer", ":=", "time", ".", "NewTi...
// WaitTimeout takes a time.Duration to wait for the flow associated with the // Token to complete, returns true if it returned before the timeout or // returns false if the timeout occurred. In the case of a timeout the Token // does not have an error set in case the caller wishes to wait again
[ "WaitTimeout", "takes", "a", "time", ".", "Duration", "to", "wait", "for", "the", "flow", "associated", "with", "the", "Token", "to", "complete", "returns", "true", "if", "it", "returned", "before", "the", "timeout", "or", "returns", "false", "if", "the", ...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/token.go#L66-L81
24,405
eclipse/paho.mqtt.golang
token.go
Result
func (s *SubscribeToken) Result() map[string]byte { s.m.RLock() defer s.m.RUnlock() return s.subResult }
go
func (s *SubscribeToken) Result() map[string]byte { s.m.RLock() defer s.m.RUnlock() return s.subResult }
[ "func", "(", "s", "*", "SubscribeToken", ")", "Result", "(", ")", "map", "[", "string", "]", "byte", "{", "s", ".", "m", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "m", ".", "RUnlock", "(", ")", "\n", "return", "s", ".", "subResult", "\n"...
// Result returns a map of topics that were subscribed to along with // the matching return code from the broker. This is either the Qos // value of the subscription or an error code.
[ "Result", "returns", "a", "map", "of", "topics", "that", "were", "subscribed", "to", "along", "with", "the", "matching", "return", "code", "from", "the", "broker", ".", "This", "is", "either", "the", "Qos", "value", "of", "the", "subscription", "or", "an",...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/token.go#L168-L172
24,406
eclipse/paho.mqtt.golang
options_reader.go
Servers
func (r *ClientOptionsReader) Servers() []*url.URL { s := make([]*url.URL, len(r.options.Servers)) for i, u := range r.options.Servers { nu := *u s[i] = &nu } return s }
go
func (r *ClientOptionsReader) Servers() []*url.URL { s := make([]*url.URL, len(r.options.Servers)) for i, u := range r.options.Servers { nu := *u s[i] = &nu } return s }
[ "func", "(", "r", "*", "ClientOptionsReader", ")", "Servers", "(", ")", "[", "]", "*", "url", ".", "URL", "{", "s", ":=", "make", "(", "[", "]", "*", "url", ".", "URL", ",", "len", "(", "r", ".", "options", ".", "Servers", ")", ")", "\n\n", "...
//Servers returns a slice of the servers defined in the clientoptions
[ "Servers", "returns", "a", "slice", "of", "the", "servers", "defined", "in", "the", "clientoptions" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/options_reader.go#L30-L39
24,407
eclipse/paho.mqtt.golang
memstore.go
Open
func (store *MemoryStore) Open() { store.Lock() defer store.Unlock() store.opened = true DEBUG.Println(STR, "memorystore initialized") }
go
func (store *MemoryStore) Open() { store.Lock() defer store.Unlock() store.opened = true DEBUG.Println(STR, "memorystore initialized") }
[ "func", "(", "store", "*", "MemoryStore", ")", "Open", "(", ")", "{", "store", ".", "Lock", "(", ")", "\n", "defer", "store", ".", "Unlock", "(", ")", "\n", "store", ".", "opened", "=", "true", "\n", "DEBUG", ".", "Println", "(", "STR", ",", "\""...
// Open initializes a MemoryStore instance.
[ "Open", "initializes", "a", "MemoryStore", "instance", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/memstore.go#L44-L49
24,408
eclipse/paho.mqtt.golang
memstore.go
Get
func (store *MemoryStore) Get(key string) packets.ControlPacket { store.RLock() defer store.RUnlock() if !store.opened { ERROR.Println(STR, "Trying to use memory store, but not open") return nil } mid := mIDFromKey(key) m := store.messages[key] if m == nil { CRITICAL.Println(STR, "memorystore get: message"...
go
func (store *MemoryStore) Get(key string) packets.ControlPacket { store.RLock() defer store.RUnlock() if !store.opened { ERROR.Println(STR, "Trying to use memory store, but not open") return nil } mid := mIDFromKey(key) m := store.messages[key] if m == nil { CRITICAL.Println(STR, "memorystore get: message"...
[ "func", "(", "store", "*", "MemoryStore", ")", "Get", "(", "key", "string", ")", "packets", ".", "ControlPacket", "{", "store", ".", "RLock", "(", ")", "\n", "defer", "store", ".", "RUnlock", "(", ")", "\n", "if", "!", "store", ".", "opened", "{", ...
// Get takes a key and looks in the store for a matching Message // returning either the Message pointer or nil.
[ "Get", "takes", "a", "key", "and", "looks", "in", "the", "store", "for", "a", "matching", "Message", "returning", "either", "the", "Message", "pointer", "or", "nil", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/memstore.go#L65-L80
24,409
eclipse/paho.mqtt.golang
memstore.go
Del
func (store *MemoryStore) Del(key string) { store.Lock() defer store.Unlock() if !store.opened { ERROR.Println(STR, "Trying to use memory store, but not open") return } mid := mIDFromKey(key) m := store.messages[key] if m == nil { WARN.Println(STR, "memorystore del: message", mid, "not found") } else { ...
go
func (store *MemoryStore) Del(key string) { store.Lock() defer store.Unlock() if !store.opened { ERROR.Println(STR, "Trying to use memory store, but not open") return } mid := mIDFromKey(key) m := store.messages[key] if m == nil { WARN.Println(STR, "memorystore del: message", mid, "not found") } else { ...
[ "func", "(", "store", "*", "MemoryStore", ")", "Del", "(", "key", "string", ")", "{", "store", ".", "Lock", "(", ")", "\n", "defer", "store", ".", "Unlock", "(", ")", "\n", "if", "!", "store", ".", "opened", "{", "ERROR", ".", "Println", "(", "ST...
// Del takes a key, searches the MemoryStore and if the key is found // deletes the Message pointer associated with it.
[ "Del", "takes", "a", "key", "searches", "the", "MemoryStore", "and", "if", "the", "key", "is", "found", "deletes", "the", "Message", "pointer", "associated", "with", "it", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/memstore.go#L100-L115
24,410
eclipse/paho.mqtt.golang
client.go
AddRoute
func (c *client) AddRoute(topic string, callback MessageHandler) { if callback != nil { c.msgRouter.addRoute(topic, callback) } }
go
func (c *client) AddRoute(topic string, callback MessageHandler) { if callback != nil { c.msgRouter.addRoute(topic, callback) } }
[ "func", "(", "c", "*", "client", ")", "AddRoute", "(", "topic", "string", ",", "callback", "MessageHandler", ")", "{", "if", "callback", "!=", "nil", "{", "c", ".", "msgRouter", ".", "addRoute", "(", "topic", ",", "callback", ")", "\n", "}", "\n", "}...
// AddRoute allows you to add a handler for messages on a specific topic // without making a subscription. For example having a different handler // for parts of a wildcard subscription
[ "AddRoute", "allows", "you", "to", "add", "a", "handler", "for", "messages", "on", "a", "specific", "topic", "without", "making", "a", "subscription", ".", "For", "example", "having", "a", "different", "handler", "for", "parts", "of", "a", "wildcard", "subsc...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/client.go#L152-L156
24,411
eclipse/paho.mqtt.golang
client.go
IsConnectionOpen
func (c *client) IsConnectionOpen() bool { c.RLock() defer c.RUnlock() status := atomic.LoadUint32(&c.status) switch { case status == connected: return true default: return false } }
go
func (c *client) IsConnectionOpen() bool { c.RLock() defer c.RUnlock() status := atomic.LoadUint32(&c.status) switch { case status == connected: return true default: return false } }
[ "func", "(", "c", "*", "client", ")", "IsConnectionOpen", "(", ")", "bool", "{", "c", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "RUnlock", "(", ")", "\n", "status", ":=", "atomic", ".", "LoadUint32", "(", "&", "c", ".", "status", ")", "\n"...
// IsConnectionOpen return a bool signifying whether the client has an active // connection to mqtt broker, i.e not in disconnected or reconnect mode
[ "IsConnectionOpen", "return", "a", "bool", "signifying", "whether", "the", "client", "has", "an", "active", "connection", "to", "mqtt", "broker", "i", ".", "e", "not", "in", "disconnected", "or", "reconnect", "mode" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/client.go#L176-L186
24,412
eclipse/paho.mqtt.golang
client.go
Publish
func (c *client) Publish(topic string, qos byte, retained bool, payload interface{}) Token { token := newToken(packets.Publish).(*PublishToken) DEBUG.Println(CLI, "enter Publish") switch { case !c.IsConnected(): token.setError(ErrNotConnected) return token case c.connectionStatus() == reconnecting && qos == 0:...
go
func (c *client) Publish(topic string, qos byte, retained bool, payload interface{}) Token { token := newToken(packets.Publish).(*PublishToken) DEBUG.Println(CLI, "enter Publish") switch { case !c.IsConnected(): token.setError(ErrNotConnected) return token case c.connectionStatus() == reconnecting && qos == 0:...
[ "func", "(", "c", "*", "client", ")", "Publish", "(", "topic", "string", ",", "qos", "byte", ",", "retained", "bool", ",", "payload", "interface", "{", "}", ")", "Token", "{", "token", ":=", "newToken", "(", "packets", ".", "Publish", ")", ".", "(", ...
// Publish will publish a message with the specified QoS and content // to the specified topic. // Returns a token to track delivery of the message to the broker
[ "Publish", "will", "publish", "a", "message", "with", "the", "specified", "QoS", "and", "content", "to", "the", "specified", "topic", ".", "Returns", "a", "token", "to", "track", "delivery", "of", "the", "message", "to", "the", "broker" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/client.go#L568-L605
24,413
eclipse/paho.mqtt.golang
client.go
resume
func (c *client) resume(subscription bool) { storedKeys := c.persist.All() for _, key := range storedKeys { packet := c.persist.Get(key) if packet == nil { continue } details := packet.Details() if isKeyOutbound(key) { switch packet.(type) { case *packets.SubscribePacket: if subscription { ...
go
func (c *client) resume(subscription bool) { storedKeys := c.persist.All() for _, key := range storedKeys { packet := c.persist.Get(key) if packet == nil { continue } details := packet.Details() if isKeyOutbound(key) { switch packet.(type) { case *packets.SubscribePacket: if subscription { ...
[ "func", "(", "c", "*", "client", ")", "resume", "(", "subscription", "bool", ")", "{", "storedKeys", ":=", "c", ".", "persist", ".", "All", "(", ")", "\n", "for", "_", ",", "key", ":=", "range", "storedKeys", "{", "packet", ":=", "c", ".", "persist...
// Load all stored messages and resend them // Call this to ensure QOS > 1,2 even after an application crash
[ "Load", "all", "stored", "messages", "and", "resend", "them", "Call", "this", "to", "ensure", "QOS", ">", "1", "2", "even", "after", "an", "application", "crash" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/client.go#L669-L723
24,414
eclipse/paho.mqtt.golang
client.go
OptionsReader
func (c *client) OptionsReader() ClientOptionsReader { r := ClientOptionsReader{options: &c.options} return r }
go
func (c *client) OptionsReader() ClientOptionsReader { r := ClientOptionsReader{options: &c.options} return r }
[ "func", "(", "c", "*", "client", ")", "OptionsReader", "(", ")", "ClientOptionsReader", "{", "r", ":=", "ClientOptionsReader", "{", "options", ":", "&", "c", ".", "options", "}", "\n", "return", "r", "\n", "}" ]
// OptionsReader returns a ClientOptionsReader which is a copy of the clientoptions // in use by the client.
[ "OptionsReader", "returns", "a", "ClientOptionsReader", "which", "is", "a", "copy", "of", "the", "clientoptions", "in", "use", "by", "the", "client", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/client.go#L750-L753
24,415
eclipse/paho.mqtt.golang
packets/publish.go
Copy
func (p *PublishPacket) Copy() *PublishPacket { newP := NewControlPacket(Publish).(*PublishPacket) newP.TopicName = p.TopicName newP.Payload = p.Payload return newP }
go
func (p *PublishPacket) Copy() *PublishPacket { newP := NewControlPacket(Publish).(*PublishPacket) newP.TopicName = p.TopicName newP.Payload = p.Payload return newP }
[ "func", "(", "p", "*", "PublishPacket", ")", "Copy", "(", ")", "*", "PublishPacket", "{", "newP", ":=", "NewControlPacket", "(", "Publish", ")", ".", "(", "*", "PublishPacket", ")", "\n", "newP", ".", "TopicName", "=", "p", ".", "TopicName", "\n", "new...
//Copy creates a new PublishPacket with the same topic and payload //but an empty fixed header, useful for when you want to deliver //a message with different properties such as Qos but the same //content
[ "Copy", "creates", "a", "new", "PublishPacket", "with", "the", "same", "topic", "and", "payload", "but", "an", "empty", "fixed", "header", "useful", "for", "when", "you", "want", "to", "deliver", "a", "message", "with", "different", "properties", "such", "as...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/packets/publish.go#L76-L82
24,416
eclipse/paho.mqtt.golang
filestore.go
NewFileStore
func NewFileStore(directory string) *FileStore { store := &FileStore{ directory: directory, opened: false, } return store }
go
func NewFileStore(directory string) *FileStore { store := &FileStore{ directory: directory, opened: false, } return store }
[ "func", "NewFileStore", "(", "directory", "string", ")", "*", "FileStore", "{", "store", ":=", "&", "FileStore", "{", "directory", ":", "directory", ",", "opened", ":", "false", ",", "}", "\n", "return", "store", "\n", "}" ]
// NewFileStore will create a new FileStore which stores its messages in the // directory provided.
[ "NewFileStore", "will", "create", "a", "new", "FileStore", "which", "stores", "its", "messages", "in", "the", "directory", "provided", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/filestore.go#L46-L52
24,417
eclipse/paho.mqtt.golang
filestore.go
Open
func (store *FileStore) Open() { store.Lock() defer store.Unlock() // if no store directory was specified in ClientOpts, by default use the // current working directory if store.directory == "" { store.directory, _ = os.Getwd() } // if store dir exists, great, otherwise, create it if !exists(store.directory)...
go
func (store *FileStore) Open() { store.Lock() defer store.Unlock() // if no store directory was specified in ClientOpts, by default use the // current working directory if store.directory == "" { store.directory, _ = os.Getwd() } // if store dir exists, great, otherwise, create it if !exists(store.directory)...
[ "func", "(", "store", "*", "FileStore", ")", "Open", "(", ")", "{", "store", ".", "Lock", "(", ")", "\n", "defer", "store", ".", "Unlock", "(", ")", "\n", "// if no store directory was specified in ClientOpts, by default use the", "// current working directory", "if...
// Open will allow the FileStore to be used.
[ "Open", "will", "allow", "the", "FileStore", "to", "be", "used", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/filestore.go#L55-L72
24,418
eclipse/paho.mqtt.golang
filestore.go
All
func (store *FileStore) All() []string { store.RLock() defer store.RUnlock() return store.all() }
go
func (store *FileStore) All() []string { store.RLock() defer store.RUnlock() return store.all() }
[ "func", "(", "store", "*", "FileStore", ")", "All", "(", ")", "[", "]", "string", "{", "store", ".", "RLock", "(", ")", "\n", "defer", "store", ".", "RUnlock", "(", ")", "\n", "return", "store", ".", "all", "(", ")", "\n", "}" ]
// All will provide a list of all of the keys associated with messages // currenly residing in the FileStore.
[ "All", "will", "provide", "a", "list", "of", "all", "of", "the", "keys", "associated", "with", "messages", "currenly", "residing", "in", "the", "FileStore", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/filestore.go#L128-L132
24,419
eclipse/paho.mqtt.golang
filestore.go
Del
func (store *FileStore) Del(key string) { store.Lock() defer store.Unlock() store.del(key) }
go
func (store *FileStore) Del(key string) { store.Lock() defer store.Unlock() store.del(key) }
[ "func", "(", "store", "*", "FileStore", ")", "Del", "(", "key", "string", ")", "{", "store", ".", "Lock", "(", ")", "\n", "defer", "store", ".", "Unlock", "(", ")", "\n", "store", ".", "del", "(", "key", ")", "\n", "}" ]
// Del will remove the persisted message associated with the provided // key from the FileStore.
[ "Del", "will", "remove", "the", "persisted", "message", "associated", "with", "the", "provided", "key", "from", "the", "FileStore", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/filestore.go#L136-L140
24,420
eclipse/paho.mqtt.golang
filestore.go
Reset
func (store *FileStore) Reset() { store.Lock() defer store.Unlock() WARN.Println(STR, "FileStore Reset") for _, key := range store.all() { store.del(key) } }
go
func (store *FileStore) Reset() { store.Lock() defer store.Unlock() WARN.Println(STR, "FileStore Reset") for _, key := range store.all() { store.del(key) } }
[ "func", "(", "store", "*", "FileStore", ")", "Reset", "(", ")", "{", "store", ".", "Lock", "(", ")", "\n", "defer", "store", ".", "Unlock", "(", ")", "\n", "WARN", ".", "Println", "(", "STR", ",", "\"", "\"", ")", "\n", "for", "_", ",", "key", ...
// Reset will remove all persisted messages from the FileStore.
[ "Reset", "will", "remove", "all", "persisted", "messages", "from", "the", "FileStore", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/filestore.go#L143-L150
24,421
eclipse/paho.mqtt.golang
router.go
newRouter
func newRouter() (*router, chan bool) { router := &router{routes: list.New(), messages: make(chan *packets.PublishPacket), stop: make(chan bool)} stop := router.stop return router, stop }
go
func newRouter() (*router, chan bool) { router := &router{routes: list.New(), messages: make(chan *packets.PublishPacket), stop: make(chan bool)} stop := router.stop return router, stop }
[ "func", "newRouter", "(", ")", "(", "*", "router", ",", "chan", "bool", ")", "{", "router", ":=", "&", "router", "{", "routes", ":", "list", ".", "New", "(", ")", ",", "messages", ":", "make", "(", "chan", "*", "packets", ".", "PublishPacket", ")",...
// newRouter returns a new instance of a Router and channel which can be used to tell the Router // to stop
[ "newRouter", "returns", "a", "new", "instance", "of", "a", "Router", "and", "channel", "which", "can", "be", "used", "to", "tell", "the", "Router", "to", "stop" ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/router.go#L95-L99
24,422
eclipse/paho.mqtt.golang
router.go
addRoute
func (r *router) addRoute(topic string, callback MessageHandler) { r.Lock() defer r.Unlock() for e := r.routes.Front(); e != nil; e = e.Next() { if e.Value.(*route).match(topic) { r := e.Value.(*route) r.callback = callback return } } r.routes.PushBack(&route{topic: topic, callback: callback}) }
go
func (r *router) addRoute(topic string, callback MessageHandler) { r.Lock() defer r.Unlock() for e := r.routes.Front(); e != nil; e = e.Next() { if e.Value.(*route).match(topic) { r := e.Value.(*route) r.callback = callback return } } r.routes.PushBack(&route{topic: topic, callback: callback}) }
[ "func", "(", "r", "*", "router", ")", "addRoute", "(", "topic", "string", ",", "callback", "MessageHandler", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "for", "e", ":=", "r", ".", "routes", ".", "Fron...
// addRoute takes a topic string and MessageHandler callback. It looks in the current list of // routes to see if there is already a matching Route. If there is it replaces the current // callback with the new one. If not it add a new entry to the list of Routes.
[ "addRoute", "takes", "a", "topic", "string", "and", "MessageHandler", "callback", ".", "It", "looks", "in", "the", "current", "list", "of", "routes", "to", "see", "if", "there", "is", "already", "a", "matching", "Route", ".", "If", "there", "is", "it", "...
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/router.go#L104-L115
24,423
eclipse/paho.mqtt.golang
router.go
deleteRoute
func (r *router) deleteRoute(topic string) { r.Lock() defer r.Unlock() for e := r.routes.Front(); e != nil; e = e.Next() { if e.Value.(*route).match(topic) { r.routes.Remove(e) return } } }
go
func (r *router) deleteRoute(topic string) { r.Lock() defer r.Unlock() for e := r.routes.Front(); e != nil; e = e.Next() { if e.Value.(*route).match(topic) { r.routes.Remove(e) return } } }
[ "func", "(", "r", "*", "router", ")", "deleteRoute", "(", "topic", "string", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "for", "e", ":=", "r", ".", "routes", ".", "Front", "(", ")", ";", "e", "!="...
// deleteRoute takes a route string, looks for a matching Route in the list of Routes. If // found it removes the Route from the list.
[ "deleteRoute", "takes", "a", "route", "string", "looks", "for", "a", "matching", "Route", "in", "the", "list", "of", "Routes", ".", "If", "found", "it", "removes", "the", "Route", "from", "the", "list", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/router.go#L119-L128
24,424
eclipse/paho.mqtt.golang
router.go
setDefaultHandler
func (r *router) setDefaultHandler(handler MessageHandler) { r.Lock() defer r.Unlock() r.defaultHandler = handler }
go
func (r *router) setDefaultHandler(handler MessageHandler) { r.Lock() defer r.Unlock() r.defaultHandler = handler }
[ "func", "(", "r", "*", "router", ")", "setDefaultHandler", "(", "handler", "MessageHandler", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "r", ".", "defaultHandler", "=", "handler", "\n", "}" ]
// setDefaultHandler assigns a default callback that will be called if no matching Route // is found for an incoming Publish.
[ "setDefaultHandler", "assigns", "a", "default", "callback", "that", "will", "be", "called", "if", "no", "matching", "Route", "is", "found", "for", "an", "incoming", "Publish", "." ]
adca289fdcf8c883800aafa545bc263452290bae
https://github.com/eclipse/paho.mqtt.golang/blob/adca289fdcf8c883800aafa545bc263452290bae/router.go#L132-L136
24,425
nats-io/go-nats
enc.go
NewEncodedConn
func NewEncodedConn(c *Conn, encType string) (*EncodedConn, error) { if c == nil { return nil, errors.New("nats: Nil Connection") } if c.IsClosed() { return nil, ErrConnectionClosed } ec := &EncodedConn{Conn: c, Enc: EncoderForType(encType)} if ec.Enc == nil { return nil, fmt.Errorf("no encoder registered f...
go
func NewEncodedConn(c *Conn, encType string) (*EncodedConn, error) { if c == nil { return nil, errors.New("nats: Nil Connection") } if c.IsClosed() { return nil, ErrConnectionClosed } ec := &EncodedConn{Conn: c, Enc: EncoderForType(encType)} if ec.Enc == nil { return nil, fmt.Errorf("no encoder registered f...
[ "func", "NewEncodedConn", "(", "c", "*", "Conn", ",", "encType", "string", ")", "(", "*", "EncodedConn", ",", "error", ")", "{", "if", "c", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if",...
// NewEncodedConn will wrap an existing Connection and utilize the appropriate registered // encoder.
[ "NewEncodedConn", "will", "wrap", "an", "existing", "Connection", "and", "utilize", "the", "appropriate", "registered", "encoder", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L61-L73
24,426
nats-io/go-nats
enc.go
RegisterEncoder
func RegisterEncoder(encType string, enc Encoder) { encLock.Lock() defer encLock.Unlock() encMap[encType] = enc }
go
func RegisterEncoder(encType string, enc Encoder) { encLock.Lock() defer encLock.Unlock() encMap[encType] = enc }
[ "func", "RegisterEncoder", "(", "encType", "string", ",", "enc", "Encoder", ")", "{", "encLock", ".", "Lock", "(", ")", "\n", "defer", "encLock", ".", "Unlock", "(", ")", "\n", "encMap", "[", "encType", "]", "=", "enc", "\n", "}" ]
// RegisterEncoder will register the encType with the given Encoder. Useful for customization.
[ "RegisterEncoder", "will", "register", "the", "encType", "with", "the", "given", "Encoder", ".", "Useful", "for", "customization", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L76-L80
24,427
nats-io/go-nats
enc.go
EncoderForType
func EncoderForType(encType string) Encoder { encLock.Lock() defer encLock.Unlock() return encMap[encType] }
go
func EncoderForType(encType string) Encoder { encLock.Lock() defer encLock.Unlock() return encMap[encType] }
[ "func", "EncoderForType", "(", "encType", "string", ")", "Encoder", "{", "encLock", ".", "Lock", "(", ")", "\n", "defer", "encLock", ".", "Unlock", "(", ")", "\n", "return", "encMap", "[", "encType", "]", "\n", "}" ]
// EncoderForType will return the registered Encoder for the encType.
[ "EncoderForType", "will", "return", "the", "registered", "Encoder", "for", "the", "encType", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L83-L87
24,428
nats-io/go-nats
enc.go
Publish
func (c *EncodedConn) Publish(subject string, v interface{}) error { b, err := c.Enc.Encode(subject, v) if err != nil { return err } return c.Conn.publish(subject, _EMPTY_, b) }
go
func (c *EncodedConn) Publish(subject string, v interface{}) error { b, err := c.Enc.Encode(subject, v) if err != nil { return err } return c.Conn.publish(subject, _EMPTY_, b) }
[ "func", "(", "c", "*", "EncodedConn", ")", "Publish", "(", "subject", "string", ",", "v", "interface", "{", "}", ")", "error", "{", "b", ",", "err", ":=", "c", ".", "Enc", ".", "Encode", "(", "subject", ",", "v", ")", "\n", "if", "err", "!=", "...
// Publish publishes the data argument to the given subject. The data argument // will be encoded using the associated encoder.
[ "Publish", "publishes", "the", "data", "argument", "to", "the", "given", "subject", ".", "The", "data", "argument", "will", "be", "encoded", "using", "the", "associated", "encoder", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L91-L97
24,429
nats-io/go-nats
enc.go
argInfo
func argInfo(cb Handler) (reflect.Type, int) { cbType := reflect.TypeOf(cb) if cbType.Kind() != reflect.Func { panic("nats: Handler needs to be a func") } numArgs := cbType.NumIn() if numArgs == 0 { return nil, numArgs } return cbType.In(numArgs - 1), numArgs }
go
func argInfo(cb Handler) (reflect.Type, int) { cbType := reflect.TypeOf(cb) if cbType.Kind() != reflect.Func { panic("nats: Handler needs to be a func") } numArgs := cbType.NumIn() if numArgs == 0 { return nil, numArgs } return cbType.In(numArgs - 1), numArgs }
[ "func", "argInfo", "(", "cb", "Handler", ")", "(", "reflect", ".", "Type", ",", "int", ")", "{", "cbType", ":=", "reflect", ".", "TypeOf", "(", "cb", ")", "\n", "if", "cbType", ".", "Kind", "(", ")", "!=", "reflect", ".", "Func", "{", "panic", "(...
// Dissect the cb Handler's signature
[ "Dissect", "the", "cb", "Handler", "s", "signature" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L156-L166
24,430
nats-io/go-nats
enc.go
Subscribe
func (c *EncodedConn) Subscribe(subject string, cb Handler) (*Subscription, error) { return c.subscribe(subject, _EMPTY_, cb) }
go
func (c *EncodedConn) Subscribe(subject string, cb Handler) (*Subscription, error) { return c.subscribe(subject, _EMPTY_, cb) }
[ "func", "(", "c", "*", "EncodedConn", ")", "Subscribe", "(", "subject", "string", ",", "cb", "Handler", ")", "(", "*", "Subscription", ",", "error", ")", "{", "return", "c", ".", "subscribe", "(", "subject", ",", "_EMPTY_", ",", "cb", ")", "\n", "}" ...
// Subscribe will create a subscription on the given subject and process incoming // messages using the specified Handler. The Handler should be a func that matches // a signature from the description of Handler from above.
[ "Subscribe", "will", "create", "a", "subscription", "on", "the", "given", "subject", "and", "process", "incoming", "messages", "using", "the", "specified", "Handler", ".", "The", "Handler", "should", "be", "a", "func", "that", "matches", "a", "signature", "fro...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L173-L175
24,431
nats-io/go-nats
enc.go
QueueSubscribe
func (c *EncodedConn) QueueSubscribe(subject, queue string, cb Handler) (*Subscription, error) { return c.subscribe(subject, queue, cb) }
go
func (c *EncodedConn) QueueSubscribe(subject, queue string, cb Handler) (*Subscription, error) { return c.subscribe(subject, queue, cb) }
[ "func", "(", "c", "*", "EncodedConn", ")", "QueueSubscribe", "(", "subject", ",", "queue", "string", ",", "cb", "Handler", ")", "(", "*", "Subscription", ",", "error", ")", "{", "return", "c", ".", "subscribe", "(", "subject", ",", "queue", ",", "cb", ...
// QueueSubscribe will create a queue subscription on the given subject and process // incoming messages using the specified Handler. The Handler should be a func that // matches a signature from the description of Handler from above.
[ "QueueSubscribe", "will", "create", "a", "queue", "subscription", "on", "the", "given", "subject", "and", "process", "incoming", "messages", "using", "the", "specified", "Handler", ".", "The", "Handler", "should", "be", "a", "func", "that", "matches", "a", "si...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L180-L182
24,432
nats-io/go-nats
enc.go
subscribe
func (c *EncodedConn) subscribe(subject, queue string, cb Handler) (*Subscription, error) { if cb == nil { return nil, errors.New("nats: Handler required for EncodedConn Subscription") } argType, numArgs := argInfo(cb) if argType == nil { return nil, errors.New("nats: Handler requires at least one argument") }...
go
func (c *EncodedConn) subscribe(subject, queue string, cb Handler) (*Subscription, error) { if cb == nil { return nil, errors.New("nats: Handler required for EncodedConn Subscription") } argType, numArgs := argInfo(cb) if argType == nil { return nil, errors.New("nats: Handler requires at least one argument") }...
[ "func", "(", "c", "*", "EncodedConn", ")", "subscribe", "(", "subject", ",", "queue", "string", ",", "cb", "Handler", ")", "(", "*", "Subscription", ",", "error", ")", "{", "if", "cb", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "...
// Internal implementation that all public functions will use.
[ "Internal", "implementation", "that", "all", "public", "functions", "will", "use", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/enc.go#L185-L238
24,433
nats-io/go-nats
parser.go
cloneMsgArg
func (nc *Conn) cloneMsgArg() { nc.ps.argBuf = nc.ps.scratch[:0] nc.ps.argBuf = append(nc.ps.argBuf, nc.ps.ma.subject...) nc.ps.argBuf = append(nc.ps.argBuf, nc.ps.ma.reply...) nc.ps.ma.subject = nc.ps.argBuf[:len(nc.ps.ma.subject)] if nc.ps.ma.reply != nil { nc.ps.ma.reply = nc.ps.argBuf[len(nc.ps.ma.subject):]...
go
func (nc *Conn) cloneMsgArg() { nc.ps.argBuf = nc.ps.scratch[:0] nc.ps.argBuf = append(nc.ps.argBuf, nc.ps.ma.subject...) nc.ps.argBuf = append(nc.ps.argBuf, nc.ps.ma.reply...) nc.ps.ma.subject = nc.ps.argBuf[:len(nc.ps.ma.subject)] if nc.ps.ma.reply != nil { nc.ps.ma.reply = nc.ps.argBuf[len(nc.ps.ma.subject):]...
[ "func", "(", "nc", "*", "Conn", ")", "cloneMsgArg", "(", ")", "{", "nc", ".", "ps", ".", "argBuf", "=", "nc", ".", "ps", ".", "scratch", "[", ":", "0", "]", "\n", "nc", ".", "ps", ".", "argBuf", "=", "append", "(", "nc", ".", "ps", ".", "ar...
// cloneMsgArg is used when the split buffer scenario has the pubArg in the existing read buffer, but // we need to hold onto it into the next read.
[ "cloneMsgArg", "is", "used", "when", "the", "split", "buffer", "scenario", "has", "the", "pubArg", "in", "the", "existing", "read", "buffer", "but", "we", "need", "to", "hold", "onto", "it", "into", "the", "next", "read", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/parser.go#L405-L413
24,434
nats-io/go-nats
nats.go
GetDefaultOptions
func GetDefaultOptions() Options { return Options{ AllowReconnect: true, MaxReconnect: DefaultMaxReconnect, ReconnectWait: DefaultReconnectWait, Timeout: DefaultTimeout, PingInterval: DefaultPingInterval, MaxPingsOut: DefaultMaxPingOut, SubChanLen: DefaultMaxChanLen, Re...
go
func GetDefaultOptions() Options { return Options{ AllowReconnect: true, MaxReconnect: DefaultMaxReconnect, ReconnectWait: DefaultReconnectWait, Timeout: DefaultTimeout, PingInterval: DefaultPingInterval, MaxPingsOut: DefaultMaxPingOut, SubChanLen: DefaultMaxChanLen, Re...
[ "func", "GetDefaultOptions", "(", ")", "Options", "{", "return", "Options", "{", "AllowReconnect", ":", "true", ",", "MaxReconnect", ":", "DefaultMaxReconnect", ",", "ReconnectWait", ":", "DefaultReconnectWait", ",", "Timeout", ":", "DefaultTimeout", ",", "PingInter...
// GetDefaultOptions returns default configuration options for the client.
[ "GetDefaultOptions", "returns", "default", "configuration", "options", "for", "the", "client", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L117-L129
24,435
nats-io/go-nats
nats.go
Name
func Name(name string) Option { return func(o *Options) error { o.Name = name return nil } }
go
func Name(name string) Option { return func(o *Options) error { o.Name = name return nil } }
[ "func", "Name", "(", "name", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Name", "=", "name", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// Options that can be passed to Connect. // Name is an Option to set the client name.
[ "Options", "that", "can", "be", "passed", "to", "Connect", ".", "Name", "is", "an", "Option", "to", "set", "the", "client", "name", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L531-L536
24,436
nats-io/go-nats
nats.go
RootCAs
func RootCAs(file ...string) Option { return func(o *Options) error { pool := x509.NewCertPool() for _, f := range file { rootPEM, err := ioutil.ReadFile(f) if err != nil || rootPEM == nil { return fmt.Errorf("nats: error loading or parsing rootCA file: %v", err) } ok := pool.AppendCertsFromPEM(roo...
go
func RootCAs(file ...string) Option { return func(o *Options) error { pool := x509.NewCertPool() for _, f := range file { rootPEM, err := ioutil.ReadFile(f) if err != nil || rootPEM == nil { return fmt.Errorf("nats: error loading or parsing rootCA file: %v", err) } ok := pool.AppendCertsFromPEM(roo...
[ "func", "RootCAs", "(", "file", "...", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "pool", ":=", "x509", ".", "NewCertPool", "(", ")", "\n", "for", "_", ",", "f", ":=", "range", "file", "{", "rootPEM...
// RootCAs is a helper option to provide the RootCAs pool from a list of filenames. // If Secure is not already set this will set it as well.
[ "RootCAs", "is", "a", "helper", "option", "to", "provide", "the", "RootCAs", "pool", "from", "a", "list", "of", "filenames", ".", "If", "Secure", "is", "not", "already", "set", "this", "will", "set", "it", "as", "well", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L557-L577
24,437
nats-io/go-nats
nats.go
ClientCert
func ClientCert(certFile, keyFile string) Option { return func(o *Options) error { cert, err := tls.LoadX509KeyPair(certFile, keyFile) if err != nil { return fmt.Errorf("nats: error loading client certificate: %v", err) } cert.Leaf, err = x509.ParseCertificate(cert.Certificate[0]) if err != nil { retur...
go
func ClientCert(certFile, keyFile string) Option { return func(o *Options) error { cert, err := tls.LoadX509KeyPair(certFile, keyFile) if err != nil { return fmt.Errorf("nats: error loading client certificate: %v", err) } cert.Leaf, err = x509.ParseCertificate(cert.Certificate[0]) if err != nil { retur...
[ "func", "ClientCert", "(", "certFile", ",", "keyFile", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "cert", ",", "err", ":=", "tls", ".", "LoadX509KeyPair", "(", "certFile", ",", "keyFile", ")", "\n", "if...
// ClientCert is a helper option to provide the client certificate from a file. // If Secure is not already set this will set it as well.
[ "ClientCert", "is", "a", "helper", "option", "to", "provide", "the", "client", "certificate", "from", "a", "file", ".", "If", "Secure", "is", "not", "already", "set", "this", "will", "set", "it", "as", "well", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L581-L598
24,438
nats-io/go-nats
nats.go
ReconnectWait
func ReconnectWait(t time.Duration) Option { return func(o *Options) error { o.ReconnectWait = t return nil } }
go
func ReconnectWait(t time.Duration) Option { return func(o *Options) error { o.ReconnectWait = t return nil } }
[ "func", "ReconnectWait", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "ReconnectWait", "=", "t", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ReconnectWait is an Option to set the wait time between reconnect attempts.
[ "ReconnectWait", "is", "an", "Option", "to", "set", "the", "wait", "time", "between", "reconnect", "attempts", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L626-L631
24,439
nats-io/go-nats
nats.go
MaxReconnects
func MaxReconnects(max int) Option { return func(o *Options) error { o.MaxReconnect = max return nil } }
go
func MaxReconnects(max int) Option { return func(o *Options) error { o.MaxReconnect = max return nil } }
[ "func", "MaxReconnects", "(", "max", "int", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "MaxReconnect", "=", "max", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// MaxReconnects is an Option to set the maximum number of reconnect attempts.
[ "MaxReconnects", "is", "an", "Option", "to", "set", "the", "maximum", "number", "of", "reconnect", "attempts", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L634-L639
24,440
nats-io/go-nats
nats.go
MaxPingsOutstanding
func MaxPingsOutstanding(max int) Option { return func(o *Options) error { o.MaxPingsOut = max return nil } }
go
func MaxPingsOutstanding(max int) Option { return func(o *Options) error { o.MaxPingsOut = max return nil } }
[ "func", "MaxPingsOutstanding", "(", "max", "int", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "MaxPingsOut", "=", "max", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// MaxPingsOutstanding is an Option to set the maximum number of ping requests // that can go un-answered by the server before closing the connection.
[ "MaxPingsOutstanding", "is", "an", "Option", "to", "set", "the", "maximum", "number", "of", "ping", "requests", "that", "can", "go", "un", "-", "answered", "by", "the", "server", "before", "closing", "the", "connection", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L651-L656
24,441
nats-io/go-nats
nats.go
ReconnectBufSize
func ReconnectBufSize(size int) Option { return func(o *Options) error { o.ReconnectBufSize = size return nil } }
go
func ReconnectBufSize(size int) Option { return func(o *Options) error { o.ReconnectBufSize = size return nil } }
[ "func", "ReconnectBufSize", "(", "size", "int", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "ReconnectBufSize", "=", "size", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ReconnectBufSize sets the buffer size of messages kept while busy reconnecting.
[ "ReconnectBufSize", "sets", "the", "buffer", "size", "of", "messages", "kept", "while", "busy", "reconnecting", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L659-L664
24,442
nats-io/go-nats
nats.go
DisconnectHandler
func DisconnectHandler(cb ConnHandler) Option { return func(o *Options) error { o.DisconnectedCB = cb return nil } }
go
func DisconnectHandler(cb ConnHandler) Option { return func(o *Options) error { o.DisconnectedCB = cb return nil } }
[ "func", "DisconnectHandler", "(", "cb", "ConnHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "DisconnectedCB", "=", "cb", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DisconnectHandler is an Option to set the disconnected handler.
[ "DisconnectHandler", "is", "an", "Option", "to", "set", "the", "disconnected", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L691-L696
24,443
nats-io/go-nats
nats.go
ReconnectHandler
func ReconnectHandler(cb ConnHandler) Option { return func(o *Options) error { o.ReconnectedCB = cb return nil } }
go
func ReconnectHandler(cb ConnHandler) Option { return func(o *Options) error { o.ReconnectedCB = cb return nil } }
[ "func", "ReconnectHandler", "(", "cb", "ConnHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "ReconnectedCB", "=", "cb", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ReconnectHandler is an Option to set the reconnected handler.
[ "ReconnectHandler", "is", "an", "Option", "to", "set", "the", "reconnected", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L699-L704
24,444
nats-io/go-nats
nats.go
ClosedHandler
func ClosedHandler(cb ConnHandler) Option { return func(o *Options) error { o.ClosedCB = cb return nil } }
go
func ClosedHandler(cb ConnHandler) Option { return func(o *Options) error { o.ClosedCB = cb return nil } }
[ "func", "ClosedHandler", "(", "cb", "ConnHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "ClosedCB", "=", "cb", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ClosedHandler is an Option to set the closed handler.
[ "ClosedHandler", "is", "an", "Option", "to", "set", "the", "closed", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L707-L712
24,445
nats-io/go-nats
nats.go
DiscoveredServersHandler
func DiscoveredServersHandler(cb ConnHandler) Option { return func(o *Options) error { o.DiscoveredServersCB = cb return nil } }
go
func DiscoveredServersHandler(cb ConnHandler) Option { return func(o *Options) error { o.DiscoveredServersCB = cb return nil } }
[ "func", "DiscoveredServersHandler", "(", "cb", "ConnHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "DiscoveredServersCB", "=", "cb", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DiscoveredServersHandler is an Option to set the new servers handler.
[ "DiscoveredServersHandler", "is", "an", "Option", "to", "set", "the", "new", "servers", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L715-L720
24,446
nats-io/go-nats
nats.go
ErrorHandler
func ErrorHandler(cb ErrHandler) Option { return func(o *Options) error { o.AsyncErrorCB = cb return nil } }
go
func ErrorHandler(cb ErrHandler) Option { return func(o *Options) error { o.AsyncErrorCB = cb return nil } }
[ "func", "ErrorHandler", "(", "cb", "ErrHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "AsyncErrorCB", "=", "cb", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// ErrorHandler is an Option to set the async error handler.
[ "ErrorHandler", "is", "an", "Option", "to", "set", "the", "async", "error", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L723-L728
24,447
nats-io/go-nats
nats.go
UserInfo
func UserInfo(user, password string) Option { return func(o *Options) error { o.User = user o.Password = password return nil } }
go
func UserInfo(user, password string) Option { return func(o *Options) error { o.User = user o.Password = password return nil } }
[ "func", "UserInfo", "(", "user", ",", "password", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "User", "=", "user", "\n", "o", ".", "Password", "=", "password", "\n", "return", "nil", "\n", ...
// UserInfo is an Option to set the username and password to // use when not included directly in the URLs.
[ "UserInfo", "is", "an", "Option", "to", "set", "the", "username", "and", "password", "to", "use", "when", "not", "included", "directly", "in", "the", "URLs", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L732-L738
24,448
nats-io/go-nats
nats.go
Token
func Token(token string) Option { return func(o *Options) error { if o.TokenHandler != nil { return ErrTokenAlreadySet } o.Token = token return nil } }
go
func Token(token string) Option { return func(o *Options) error { if o.TokenHandler != nil { return ErrTokenAlreadySet } o.Token = token return nil } }
[ "func", "Token", "(", "token", "string", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "if", "o", ".", "TokenHandler", "!=", "nil", "{", "return", "ErrTokenAlreadySet", "\n", "}", "\n", "o", ".", "Token", "=", "to...
// Token is an Option to set the token to use // when a token is not included directly in the URLs // and when a token handler is not provided.
[ "Token", "is", "an", "Option", "to", "set", "the", "token", "to", "use", "when", "a", "token", "is", "not", "included", "directly", "in", "the", "URLs", "and", "when", "a", "token", "handler", "is", "not", "provided", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L743-L751
24,449
nats-io/go-nats
nats.go
TokenHandler
func TokenHandler(cb AuthTokenHandler) Option { return func(o *Options) error { if o.Token != "" { return ErrTokenAlreadySet } o.TokenHandler = cb return nil } }
go
func TokenHandler(cb AuthTokenHandler) Option { return func(o *Options) error { if o.Token != "" { return ErrTokenAlreadySet } o.TokenHandler = cb return nil } }
[ "func", "TokenHandler", "(", "cb", "AuthTokenHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "if", "o", ".", "Token", "!=", "\"", "\"", "{", "return", "ErrTokenAlreadySet", "\n", "}", "\n", "o", ".", "TokenH...
// TokenHandler is an Option to set the token handler to use // when a token is not included directly in the URLs // and when a token is not set.
[ "TokenHandler", "is", "an", "Option", "to", "set", "the", "token", "handler", "to", "use", "when", "a", "token", "is", "not", "included", "directly", "in", "the", "URLs", "and", "when", "a", "token", "is", "not", "set", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L756-L764
24,450
nats-io/go-nats
nats.go
UserCredentials
func UserCredentials(userOrChainedFile string, seedFiles ...string) Option { userCB := func() (string, error) { return userFromFile(userOrChainedFile) } var keyFile string if len(seedFiles) > 0 { keyFile = seedFiles[0] } else { keyFile = userOrChainedFile } sigCB := func(nonce []byte) ([]byte, error) { r...
go
func UserCredentials(userOrChainedFile string, seedFiles ...string) Option { userCB := func() (string, error) { return userFromFile(userOrChainedFile) } var keyFile string if len(seedFiles) > 0 { keyFile = seedFiles[0] } else { keyFile = userOrChainedFile } sigCB := func(nonce []byte) ([]byte, error) { r...
[ "func", "UserCredentials", "(", "userOrChainedFile", "string", ",", "seedFiles", "...", "string", ")", "Option", "{", "userCB", ":=", "func", "(", ")", "(", "string", ",", "error", ")", "{", "return", "userFromFile", "(", "userOrChainedFile", ")", "\n", "}",...
// UserCredentials is a convenience function that takes a filename // for a user's JWT and a filename for the user's private Nkey seed.
[ "UserCredentials", "is", "a", "convenience", "function", "that", "takes", "a", "filename", "for", "a", "user", "s", "JWT", "and", "a", "filename", "for", "the", "user", "s", "private", "Nkey", "seed", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L768-L782
24,451
nats-io/go-nats
nats.go
UserJWT
func UserJWT(userCB UserJWTHandler, sigCB SignatureHandler) Option { return func(o *Options) error { if userCB == nil { return ErrNoUserCB } if sigCB == nil { return ErrUserButNoSigCB } o.UserJWT = userCB o.SignatureCB = sigCB return nil } }
go
func UserJWT(userCB UserJWTHandler, sigCB SignatureHandler) Option { return func(o *Options) error { if userCB == nil { return ErrNoUserCB } if sigCB == nil { return ErrUserButNoSigCB } o.UserJWT = userCB o.SignatureCB = sigCB return nil } }
[ "func", "UserJWT", "(", "userCB", "UserJWTHandler", ",", "sigCB", "SignatureHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "if", "userCB", "==", "nil", "{", "return", "ErrNoUserCB", "\n", "}", "\n", "if", "si...
// UserJWT will set the callbacks to retrieve the user's JWT and // the signature callback to sign the server nonce. This an the Nkey // option are mutually exclusive.
[ "UserJWT", "will", "set", "the", "callbacks", "to", "retrieve", "the", "user", "s", "JWT", "and", "the", "signature", "callback", "to", "sign", "the", "server", "nonce", ".", "This", "an", "the", "Nkey", "option", "are", "mutually", "exclusive", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L787-L799
24,452
nats-io/go-nats
nats.go
Nkey
func Nkey(pubKey string, sigCB SignatureHandler) Option { return func(o *Options) error { o.Nkey = pubKey o.SignatureCB = sigCB if pubKey != "" && sigCB == nil { return ErrNkeyButNoSigCB } return nil } }
go
func Nkey(pubKey string, sigCB SignatureHandler) Option { return func(o *Options) error { o.Nkey = pubKey o.SignatureCB = sigCB if pubKey != "" && sigCB == nil { return ErrNkeyButNoSigCB } return nil } }
[ "func", "Nkey", "(", "pubKey", "string", ",", "sigCB", "SignatureHandler", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "Nkey", "=", "pubKey", "\n", "o", ".", "SignatureCB", "=", "sigCB", "\n", "if", "p...
// Nkey will set the public Nkey and the signature callback to // sign the server nonce.
[ "Nkey", "will", "set", "the", "public", "Nkey", "and", "the", "signature", "callback", "to", "sign", "the", "server", "nonce", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L803-L812
24,453
nats-io/go-nats
nats.go
SetCustomDialer
func SetCustomDialer(dialer CustomDialer) Option { return func(o *Options) error { o.CustomDialer = dialer return nil } }
go
func SetCustomDialer(dialer CustomDialer) Option { return func(o *Options) error { o.CustomDialer = dialer return nil } }
[ "func", "SetCustomDialer", "(", "dialer", "CustomDialer", ")", "Option", "{", "return", "func", "(", "o", "*", "Options", ")", "error", "{", "o", ".", "CustomDialer", "=", "dialer", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// SetCustomDialer is an Option to set a custom dialer which will be // used when attempting to establish a connection. If both Dialer // and CustomDialer are specified, CustomDialer takes precedence.
[ "SetCustomDialer", "is", "an", "Option", "to", "set", "a", "custom", "dialer", "which", "will", "be", "used", "when", "attempting", "to", "establish", "a", "connection", ".", "If", "both", "Dialer", "and", "CustomDialer", "are", "specified", "CustomDialer", "t...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L836-L841
24,454
nats-io/go-nats
nats.go
SetDisconnectHandler
func (nc *Conn) SetDisconnectHandler(dcb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.DisconnectedCB = dcb }
go
func (nc *Conn) SetDisconnectHandler(dcb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.DisconnectedCB = dcb }
[ "func", "(", "nc", "*", "Conn", ")", "SetDisconnectHandler", "(", "dcb", "ConnHandler", ")", "{", "if", "nc", "==", "nil", "{", "return", "\n", "}", "\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "Unlock", "(",...
// Handler processing // SetDisconnectHandler will set the disconnect event handler.
[ "Handler", "processing", "SetDisconnectHandler", "will", "set", "the", "disconnect", "event", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L854-L861
24,455
nats-io/go-nats
nats.go
SetReconnectHandler
func (nc *Conn) SetReconnectHandler(rcb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.ReconnectedCB = rcb }
go
func (nc *Conn) SetReconnectHandler(rcb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.ReconnectedCB = rcb }
[ "func", "(", "nc", "*", "Conn", ")", "SetReconnectHandler", "(", "rcb", "ConnHandler", ")", "{", "if", "nc", "==", "nil", "{", "return", "\n", "}", "\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "Unlock", "(", ...
// SetReconnectHandler will set the reconnect event handler.
[ "SetReconnectHandler", "will", "set", "the", "reconnect", "event", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L864-L871
24,456
nats-io/go-nats
nats.go
SetDiscoveredServersHandler
func (nc *Conn) SetDiscoveredServersHandler(dscb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.DiscoveredServersCB = dscb }
go
func (nc *Conn) SetDiscoveredServersHandler(dscb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.DiscoveredServersCB = dscb }
[ "func", "(", "nc", "*", "Conn", ")", "SetDiscoveredServersHandler", "(", "dscb", "ConnHandler", ")", "{", "if", "nc", "==", "nil", "{", "return", "\n", "}", "\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "Unlock"...
// SetDiscoveredServersHandler will set the discovered servers handler.
[ "SetDiscoveredServersHandler", "will", "set", "the", "discovered", "servers", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L874-L881
24,457
nats-io/go-nats
nats.go
SetClosedHandler
func (nc *Conn) SetClosedHandler(cb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.ClosedCB = cb }
go
func (nc *Conn) SetClosedHandler(cb ConnHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.ClosedCB = cb }
[ "func", "(", "nc", "*", "Conn", ")", "SetClosedHandler", "(", "cb", "ConnHandler", ")", "{", "if", "nc", "==", "nil", "{", "return", "\n", "}", "\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "Unlock", "(", ")...
// SetClosedHandler will set the reconnect event handler.
[ "SetClosedHandler", "will", "set", "the", "reconnect", "event", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L884-L891
24,458
nats-io/go-nats
nats.go
SetErrorHandler
func (nc *Conn) SetErrorHandler(cb ErrHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.AsyncErrorCB = cb }
go
func (nc *Conn) SetErrorHandler(cb ErrHandler) { if nc == nil { return } nc.mu.Lock() defer nc.mu.Unlock() nc.Opts.AsyncErrorCB = cb }
[ "func", "(", "nc", "*", "Conn", ")", "SetErrorHandler", "(", "cb", "ErrHandler", ")", "{", "if", "nc", "==", "nil", "{", "return", "\n", "}", "\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "Unlock", "(", ")",...
// SetErrorHandler will set the async error handler.
[ "SetErrorHandler", "will", "set", "the", "async", "error", "handler", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L894-L901
24,459
nats-io/go-nats
nats.go
processUrlString
func processUrlString(url string) []string { urls := strings.Split(url, ",") for i, s := range urls { urls[i] = strings.TrimSpace(s) } return urls }
go
func processUrlString(url string) []string { urls := strings.Split(url, ",") for i, s := range urls { urls[i] = strings.TrimSpace(s) } return urls }
[ "func", "processUrlString", "(", "url", "string", ")", "[", "]", "string", "{", "urls", ":=", "strings", ".", "Split", "(", "url", ",", "\"", "\"", ")", "\n", "for", "i", ",", "s", ":=", "range", "urls", "{", "urls", "[", "i", "]", "=", "strings"...
// Process the url string argument to Connect. // Return an array of urls, even if only one.
[ "Process", "the", "url", "string", "argument", "to", "Connect", ".", "Return", "an", "array", "of", "urls", "even", "if", "only", "one", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L905-L911
24,460
nats-io/go-nats
nats.go
Connect
func (o Options) Connect() (*Conn, error) { nc := &Conn{Opts: o} // Some default options processing. if nc.Opts.MaxPingsOut == 0 { nc.Opts.MaxPingsOut = DefaultMaxPingOut } // Allow old default for channel length to work correctly. if nc.Opts.SubChanLen == 0 { nc.Opts.SubChanLen = DefaultMaxChanLen } // De...
go
func (o Options) Connect() (*Conn, error) { nc := &Conn{Opts: o} // Some default options processing. if nc.Opts.MaxPingsOut == 0 { nc.Opts.MaxPingsOut = DefaultMaxPingOut } // Allow old default for channel length to work correctly. if nc.Opts.SubChanLen == 0 { nc.Opts.SubChanLen = DefaultMaxChanLen } // De...
[ "func", "(", "o", "Options", ")", "Connect", "(", ")", "(", "*", "Conn", ",", "error", ")", "{", "nc", ":=", "&", "Conn", "{", "Opts", ":", "o", "}", "\n\n", "// Some default options processing.", "if", "nc", ".", "Opts", ".", "MaxPingsOut", "==", "0...
// Connect will attempt to connect to a NATS server with multiple options.
[ "Connect", "will", "attempt", "to", "connect", "to", "a", "NATS", "server", "with", "multiple", "options", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L914-L967
24,461
nats-io/go-nats
nats.go
currentServer
func (nc *Conn) currentServer() (int, *srv) { for i, s := range nc.srvPool { if s == nil { continue } if s == nc.current { return i, s } } return -1, nil }
go
func (nc *Conn) currentServer() (int, *srv) { for i, s := range nc.srvPool { if s == nil { continue } if s == nc.current { return i, s } } return -1, nil }
[ "func", "(", "nc", "*", "Conn", ")", "currentServer", "(", ")", "(", "int", ",", "*", "srv", ")", "{", "for", "i", ",", "s", ":=", "range", "nc", ".", "srvPool", "{", "if", "s", "==", "nil", "{", "continue", "\n", "}", "\n", "if", "s", "==", ...
// Return the currently selected server
[ "Return", "the", "currently", "selected", "server" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L993-L1003
24,462
nats-io/go-nats
nats.go
selectNextServer
func (nc *Conn) selectNextServer() (*srv, error) { i, s := nc.currentServer() if i < 0 { return nil, ErrNoServers } sp := nc.srvPool num := len(sp) copy(sp[i:num-1], sp[i+1:num]) maxReconnect := nc.Opts.MaxReconnect if maxReconnect < 0 || s.reconnects < maxReconnect { nc.srvPool[num-1] = s } else { nc.sr...
go
func (nc *Conn) selectNextServer() (*srv, error) { i, s := nc.currentServer() if i < 0 { return nil, ErrNoServers } sp := nc.srvPool num := len(sp) copy(sp[i:num-1], sp[i+1:num]) maxReconnect := nc.Opts.MaxReconnect if maxReconnect < 0 || s.reconnects < maxReconnect { nc.srvPool[num-1] = s } else { nc.sr...
[ "func", "(", "nc", "*", "Conn", ")", "selectNextServer", "(", ")", "(", "*", "srv", ",", "error", ")", "{", "i", ",", "s", ":=", "nc", ".", "currentServer", "(", ")", "\n", "if", "i", "<", "0", "{", "return", "nil", ",", "ErrNoServers", "\n", "...
// Pop the current server and put onto the end of the list. Select head of list as long // as number of reconnect attempts under MaxReconnect.
[ "Pop", "the", "current", "server", "and", "put", "onto", "the", "end", "of", "the", "list", ".", "Select", "head", "of", "list", "as", "long", "as", "number", "of", "reconnect", "attempts", "under", "MaxReconnect", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1007-L1027
24,463
nats-io/go-nats
nats.go
pickServer
func (nc *Conn) pickServer() error { nc.current = nil if len(nc.srvPool) <= 0 { return ErrNoServers } for _, s := range nc.srvPool { if s != nil { nc.current = s return nil } } return ErrNoServers }
go
func (nc *Conn) pickServer() error { nc.current = nil if len(nc.srvPool) <= 0 { return ErrNoServers } for _, s := range nc.srvPool { if s != nil { nc.current = s return nil } } return ErrNoServers }
[ "func", "(", "nc", "*", "Conn", ")", "pickServer", "(", ")", "error", "{", "nc", ".", "current", "=", "nil", "\n", "if", "len", "(", "nc", ".", "srvPool", ")", "<=", "0", "{", "return", "ErrNoServers", "\n", "}", "\n\n", "for", "_", ",", "s", "...
// Will assign the correct server to nc.current
[ "Will", "assign", "the", "correct", "server", "to", "nc", ".", "current" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1030-L1043
24,464
nats-io/go-nats
nats.go
setupServerPool
func (nc *Conn) setupServerPool() error { nc.srvPool = make([]*srv, 0, srvPoolSize) nc.urls = make(map[string]struct{}, srvPoolSize) // Create srv objects from each url string in nc.Opts.Servers // and add them to the pool. for _, urlString := range nc.Opts.Servers { if err := nc.addURLToPool(urlString, false, ...
go
func (nc *Conn) setupServerPool() error { nc.srvPool = make([]*srv, 0, srvPoolSize) nc.urls = make(map[string]struct{}, srvPoolSize) // Create srv objects from each url string in nc.Opts.Servers // and add them to the pool. for _, urlString := range nc.Opts.Servers { if err := nc.addURLToPool(urlString, false, ...
[ "func", "(", "nc", "*", "Conn", ")", "setupServerPool", "(", ")", "error", "{", "nc", ".", "srvPool", "=", "make", "(", "[", "]", "*", "srv", ",", "0", ",", "srvPoolSize", ")", "\n", "nc", ".", "urls", "=", "make", "(", "map", "[", "string", "]...
// Create the server pool using the options given. // We will place a Url option first, followed by any // Server Options. We will randomize the server pool unless // the NoRandomize flag is set.
[ "Create", "the", "server", "pool", "using", "the", "options", "given", ".", "We", "will", "place", "a", "Url", "option", "first", "followed", "by", "any", "Server", "Options", ".", "We", "will", "randomize", "the", "server", "pool", "unless", "the", "NoRan...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1051-L1099
24,465
nats-io/go-nats
nats.go
addURLToPool
func (nc *Conn) addURLToPool(sURL string, implicit, saveTLSName bool) error { if !strings.Contains(sURL, "://") { sURL = fmt.Sprintf("%s://%s", nc.connScheme(), sURL) } var ( u *url.URL err error ) for i := 0; i < 2; i++ { u, err = url.Parse(sURL) if err != nil { return err } if u.Port() != "" {...
go
func (nc *Conn) addURLToPool(sURL string, implicit, saveTLSName bool) error { if !strings.Contains(sURL, "://") { sURL = fmt.Sprintf("%s://%s", nc.connScheme(), sURL) } var ( u *url.URL err error ) for i := 0; i < 2; i++ { u, err = url.Parse(sURL) if err != nil { return err } if u.Port() != "" {...
[ "func", "(", "nc", "*", "Conn", ")", "addURLToPool", "(", "sURL", "string", ",", "implicit", ",", "saveTLSName", "bool", ")", "error", "{", "if", "!", "strings", ".", "Contains", "(", "sURL", ",", "\"", "\"", ")", "{", "sURL", "=", "fmt", ".", "Spr...
// addURLToPool adds an entry to the server pool
[ "addURLToPool", "adds", "an", "entry", "to", "the", "server", "pool" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1115-L1159
24,466
nats-io/go-nats
nats.go
shufflePool
func (nc *Conn) shufflePool() { if len(nc.srvPool) <= 1 { return } source := rand.NewSource(time.Now().UnixNano()) r := rand.New(source) for i := range nc.srvPool { j := r.Intn(i + 1) nc.srvPool[i], nc.srvPool[j] = nc.srvPool[j], nc.srvPool[i] } }
go
func (nc *Conn) shufflePool() { if len(nc.srvPool) <= 1 { return } source := rand.NewSource(time.Now().UnixNano()) r := rand.New(source) for i := range nc.srvPool { j := r.Intn(i + 1) nc.srvPool[i], nc.srvPool[j] = nc.srvPool[j], nc.srvPool[i] } }
[ "func", "(", "nc", "*", "Conn", ")", "shufflePool", "(", ")", "{", "if", "len", "(", "nc", ".", "srvPool", ")", "<=", "1", "{", "return", "\n", "}", "\n", "source", ":=", "rand", ".", "NewSource", "(", "time", ".", "Now", "(", ")", ".", "UnixNa...
// shufflePool swaps randomly elements in the server pool
[ "shufflePool", "swaps", "randomly", "elements", "in", "the", "server", "pool" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1162-L1172
24,467
nats-io/go-nats
nats.go
createConn
func (nc *Conn) createConn() (err error) { if nc.Opts.Timeout < 0 { return ErrBadTimeout } if _, cur := nc.currentServer(); cur == nil { return ErrNoServers } else { cur.lastAttempt = time.Now() } // We will auto-expand host names if they resolve to multiple IPs hosts := []string{} u := nc.current.url ...
go
func (nc *Conn) createConn() (err error) { if nc.Opts.Timeout < 0 { return ErrBadTimeout } if _, cur := nc.currentServer(); cur == nil { return ErrNoServers } else { cur.lastAttempt = time.Now() } // We will auto-expand host names if they resolve to multiple IPs hosts := []string{} u := nc.current.url ...
[ "func", "(", "nc", "*", "Conn", ")", "createConn", "(", ")", "(", "err", "error", ")", "{", "if", "nc", ".", "Opts", ".", "Timeout", "<", "0", "{", "return", "ErrBadTimeout", "\n", "}", "\n", "if", "_", ",", "cur", ":=", "nc", ".", "currentServer...
// createConn will connect to the server and wrap the appropriate // bufio structures. It will do the right thing when an existing // connection is in place.
[ "createConn", "will", "connect", "to", "the", "server", "and", "wrap", "the", "appropriate", "bufio", "structures", ".", "It", "will", "do", "the", "right", "thing", "when", "an", "existing", "connection", "is", "in", "place", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1185-L1248
24,468
nats-io/go-nats
nats.go
makeTLSConn
func (nc *Conn) makeTLSConn() error { // Allow the user to configure their own tls.Config structure. var tlsCopy *tls.Config if nc.Opts.TLSConfig != nil { tlsCopy = util.CloneTLSConfig(nc.Opts.TLSConfig) } else { tlsCopy = &tls.Config{} } // If its blank we will override it with the current host if tlsCopy.S...
go
func (nc *Conn) makeTLSConn() error { // Allow the user to configure their own tls.Config structure. var tlsCopy *tls.Config if nc.Opts.TLSConfig != nil { tlsCopy = util.CloneTLSConfig(nc.Opts.TLSConfig) } else { tlsCopy = &tls.Config{} } // If its blank we will override it with the current host if tlsCopy.S...
[ "func", "(", "nc", "*", "Conn", ")", "makeTLSConn", "(", ")", "error", "{", "// Allow the user to configure their own tls.Config structure.", "var", "tlsCopy", "*", "tls", ".", "Config", "\n", "if", "nc", ".", "Opts", ".", "TLSConfig", "!=", "nil", "{", "tlsCo...
// makeTLSConn will wrap an existing Conn using TLS
[ "makeTLSConn", "will", "wrap", "an", "existing", "Conn", "using", "TLS" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1251-L1275
24,469
nats-io/go-nats
nats.go
ConnectedUrl
func (nc *Conn) ConnectedUrl() string { if nc == nil { return _EMPTY_ } nc.mu.RLock() defer nc.mu.RUnlock() if nc.status != CONNECTED { return _EMPTY_ } return nc.current.url.String() }
go
func (nc *Conn) ConnectedUrl() string { if nc == nil { return _EMPTY_ } nc.mu.RLock() defer nc.mu.RUnlock() if nc.status != CONNECTED { return _EMPTY_ } return nc.current.url.String() }
[ "func", "(", "nc", "*", "Conn", ")", "ConnectedUrl", "(", ")", "string", "{", "if", "nc", "==", "nil", "{", "return", "_EMPTY_", "\n", "}", "\n\n", "nc", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "RUnlock", "(", ")...
// Report the connected server's Url
[ "Report", "the", "connected", "server", "s", "Url" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1291-L1303
24,470
nats-io/go-nats
nats.go
ConnectedAddr
func (nc *Conn) ConnectedAddr() string { if nc == nil { return _EMPTY_ } nc.mu.RLock() defer nc.mu.RUnlock() if nc.status != CONNECTED { return _EMPTY_ } return nc.conn.RemoteAddr().String() }
go
func (nc *Conn) ConnectedAddr() string { if nc == nil { return _EMPTY_ } nc.mu.RLock() defer nc.mu.RUnlock() if nc.status != CONNECTED { return _EMPTY_ } return nc.conn.RemoteAddr().String() }
[ "func", "(", "nc", "*", "Conn", ")", "ConnectedAddr", "(", ")", "string", "{", "if", "nc", "==", "nil", "{", "return", "_EMPTY_", "\n", "}", "\n\n", "nc", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "RUnlock", "(", "...
// ConnectedAddr returns the connected server's IP
[ "ConnectedAddr", "returns", "the", "connected", "server", "s", "IP" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1306-L1318
24,471
nats-io/go-nats
nats.go
ConnectedServerId
func (nc *Conn) ConnectedServerId() string { if nc == nil { return _EMPTY_ } nc.mu.RLock() defer nc.mu.RUnlock() if nc.status != CONNECTED { return _EMPTY_ } return nc.info.Id }
go
func (nc *Conn) ConnectedServerId() string { if nc == nil { return _EMPTY_ } nc.mu.RLock() defer nc.mu.RUnlock() if nc.status != CONNECTED { return _EMPTY_ } return nc.info.Id }
[ "func", "(", "nc", "*", "Conn", ")", "ConnectedServerId", "(", ")", "string", "{", "if", "nc", "==", "nil", "{", "return", "_EMPTY_", "\n", "}", "\n\n", "nc", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "nc", ".", "mu", ".", "RUnlock", "(",...
// Report the connected server's Id
[ "Report", "the", "connected", "server", "s", "Id" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1321-L1333
24,472
nats-io/go-nats
nats.go
setup
func (nc *Conn) setup() { nc.subs = make(map[int64]*Subscription) nc.pongs = make([]chan struct{}, 0, 8) nc.fch = make(chan struct{}, flushChanSize) // Setup scratch outbound buffer for PUB pub := nc.scratch[:len(_PUB_P_)] copy(pub, _PUB_P_) }
go
func (nc *Conn) setup() { nc.subs = make(map[int64]*Subscription) nc.pongs = make([]chan struct{}, 0, 8) nc.fch = make(chan struct{}, flushChanSize) // Setup scratch outbound buffer for PUB pub := nc.scratch[:len(_PUB_P_)] copy(pub, _PUB_P_) }
[ "func", "(", "nc", "*", "Conn", ")", "setup", "(", ")", "{", "nc", ".", "subs", "=", "make", "(", "map", "[", "int64", "]", "*", "Subscription", ")", "\n", "nc", ".", "pongs", "=", "make", "(", "[", "]", "chan", "struct", "{", "}", ",", "0", ...
// Low level setup for structs, etc
[ "Low", "level", "setup", "for", "structs", "etc" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1336-L1345
24,473
nats-io/go-nats
nats.go
processConnectInit
func (nc *Conn) processConnectInit() error { // Set our deadline for the whole connect process nc.conn.SetDeadline(time.Now().Add(nc.Opts.Timeout)) defer nc.conn.SetDeadline(time.Time{}) // Set our status to connecting. nc.status = CONNECTING // Process the INFO protocol received from the server err := nc.pro...
go
func (nc *Conn) processConnectInit() error { // Set our deadline for the whole connect process nc.conn.SetDeadline(time.Now().Add(nc.Opts.Timeout)) defer nc.conn.SetDeadline(time.Time{}) // Set our status to connecting. nc.status = CONNECTING // Process the INFO protocol received from the server err := nc.pro...
[ "func", "(", "nc", "*", "Conn", ")", "processConnectInit", "(", ")", "error", "{", "// Set our deadline for the whole connect process", "nc", ".", "conn", ".", "SetDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "nc", ".", "Opts", ".", "Time...
// Process a connected connection and initialize properly.
[ "Process", "a", "connected", "connection", "and", "initialize", "properly", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1348-L1388
24,474
nats-io/go-nats
nats.go
connect
func (nc *Conn) connect() error { var returnedErr error // Create actual socket connection // For first connect we walk all servers in the pool and try // to connect immediately. nc.mu.Lock() nc.initc = true // The pool may change inside the loop iteration due to INFO protocol. for i := 0; i < len(nc.srvPool);...
go
func (nc *Conn) connect() error { var returnedErr error // Create actual socket connection // For first connect we walk all servers in the pool and try // to connect immediately. nc.mu.Lock() nc.initc = true // The pool may change inside the loop iteration due to INFO protocol. for i := 0; i < len(nc.srvPool);...
[ "func", "(", "nc", "*", "Conn", ")", "connect", "(", ")", "error", "{", "var", "returnedErr", "error", "\n\n", "// Create actual socket connection", "// For first connect we walk all servers in the pool and try", "// to connect immediately.", "nc", ".", "mu", ".", "Lock",...
// Main connect function. Will connect to the nats-server
[ "Main", "connect", "function", ".", "Will", "connect", "to", "the", "nats", "-", "server" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1391-L1436
24,475
nats-io/go-nats
nats.go
checkForSecure
func (nc *Conn) checkForSecure() error { // Check to see if we need to engage TLS o := nc.Opts // Check for mismatch in setups if o.Secure && !nc.info.TLSRequired { return ErrSecureConnWanted } else if nc.info.TLSRequired && !o.Secure { // Switch to Secure since server needs TLS. o.Secure = true } // Nee...
go
func (nc *Conn) checkForSecure() error { // Check to see if we need to engage TLS o := nc.Opts // Check for mismatch in setups if o.Secure && !nc.info.TLSRequired { return ErrSecureConnWanted } else if nc.info.TLSRequired && !o.Secure { // Switch to Secure since server needs TLS. o.Secure = true } // Nee...
[ "func", "(", "nc", "*", "Conn", ")", "checkForSecure", "(", ")", "error", "{", "// Check to see if we need to engage TLS", "o", ":=", "nc", ".", "Opts", "\n\n", "// Check for mismatch in setups", "if", "o", ".", "Secure", "&&", "!", "nc", ".", "info", ".", "...
// This will check to see if the connection should be // secure. This can be dictated from either end and should // only be called after the INIT protocol has been received.
[ "This", "will", "check", "to", "see", "if", "the", "connection", "should", "be", "secure", ".", "This", "can", "be", "dictated", "from", "either", "end", "and", "should", "only", "be", "called", "after", "the", "INIT", "protocol", "has", "been", "received"...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1441-L1460
24,476
nats-io/go-nats
nats.go
processExpectedInfo
func (nc *Conn) processExpectedInfo() error { c := &control{} // Read the protocol err := nc.readOp(c) if err != nil { return err } // The nats protocol should send INFO first always. if c.op != _INFO_OP_ { return ErrNoInfoReceived } // Parse the protocol if err := nc.processInfo(c.args); err != nil {...
go
func (nc *Conn) processExpectedInfo() error { c := &control{} // Read the protocol err := nc.readOp(c) if err != nil { return err } // The nats protocol should send INFO first always. if c.op != _INFO_OP_ { return ErrNoInfoReceived } // Parse the protocol if err := nc.processInfo(c.args); err != nil {...
[ "func", "(", "nc", "*", "Conn", ")", "processExpectedInfo", "(", ")", "error", "{", "c", ":=", "&", "control", "{", "}", "\n\n", "// Read the protocol", "err", ":=", "nc", ".", "readOp", "(", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// processExpectedInfo will look for the expected first INFO message // sent when a connection is established. The lock should be held entering.
[ "processExpectedInfo", "will", "look", "for", "the", "expected", "first", "INFO", "message", "sent", "when", "a", "connection", "is", "established", ".", "The", "lock", "should", "be", "held", "entering", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1464-L1489
24,477
nats-io/go-nats
nats.go
sendProto
func (nc *Conn) sendProto(proto string) { nc.mu.Lock() nc.bw.WriteString(proto) nc.kickFlusher() nc.mu.Unlock() }
go
func (nc *Conn) sendProto(proto string) { nc.mu.Lock() nc.bw.WriteString(proto) nc.kickFlusher() nc.mu.Unlock() }
[ "func", "(", "nc", "*", "Conn", ")", "sendProto", "(", "proto", "string", ")", "{", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "nc", ".", "bw", ".", "WriteString", "(", "proto", ")", "\n", "nc", ".", "kickFlusher", "(", ")", "\n", "nc", ".",...
// Sends a protocol control message by queuing into the bufio writer // and kicking the flush Go routine. These writes are protected.
[ "Sends", "a", "protocol", "control", "message", "by", "queuing", "into", "the", "bufio", "writer", "and", "kicking", "the", "flush", "Go", "routine", ".", "These", "writes", "are", "protected", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1493-L1498
24,478
nats-io/go-nats
nats.go
normalizeErr
func normalizeErr(line string) string { s := strings.TrimSpace(strings.TrimPrefix(line, _ERR_OP_)) s = strings.TrimLeft(strings.TrimRight(s, "'"), "'") return s }
go
func normalizeErr(line string) string { s := strings.TrimSpace(strings.TrimPrefix(line, _ERR_OP_)) s = strings.TrimLeft(strings.TrimRight(s, "'"), "'") return s }
[ "func", "normalizeErr", "(", "line", "string", ")", "string", "{", "s", ":=", "strings", ".", "TrimSpace", "(", "strings", ".", "TrimPrefix", "(", "line", ",", "_ERR_OP_", ")", ")", "\n", "s", "=", "strings", ".", "TrimLeft", "(", "strings", ".", "Trim...
// normalizeErr removes the prefix -ERR, trim spaces and remove the quotes.
[ "normalizeErr", "removes", "the", "prefix", "-", "ERR", "trim", "spaces", "and", "remove", "the", "quotes", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1572-L1576
24,479
nats-io/go-nats
nats.go
readProto
func (nc *Conn) readProto() (string, error) { var ( _buf = [10]byte{} buf = _buf[:0] b = [1]byte{} protoEnd = byte('\n') ) for { if _, err := nc.conn.Read(b[:1]); err != nil { // Do not report EOF error if err == io.EOF { return string(buf), nil } return "", err } buf = ...
go
func (nc *Conn) readProto() (string, error) { var ( _buf = [10]byte{} buf = _buf[:0] b = [1]byte{} protoEnd = byte('\n') ) for { if _, err := nc.conn.Read(b[:1]); err != nil { // Do not report EOF error if err == io.EOF { return string(buf), nil } return "", err } buf = ...
[ "func", "(", "nc", "*", "Conn", ")", "readProto", "(", ")", "(", "string", ",", "error", ")", "{", "var", "(", "_buf", "=", "[", "10", "]", "byte", "{", "}", "\n", "buf", "=", "_buf", "[", ":", "0", "]", "\n", "b", "=", "[", "1", "]", "by...
// reads a protocol one byte at a time.
[ "reads", "a", "protocol", "one", "byte", "at", "a", "time", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1650-L1670
24,480
nats-io/go-nats
nats.go
readOp
func (nc *Conn) readOp(c *control) error { br := bufio.NewReaderSize(nc.conn, defaultBufSize) line, err := br.ReadString('\n') if err != nil { return err } parseControl(line, c) return nil }
go
func (nc *Conn) readOp(c *control) error { br := bufio.NewReaderSize(nc.conn, defaultBufSize) line, err := br.ReadString('\n') if err != nil { return err } parseControl(line, c) return nil }
[ "func", "(", "nc", "*", "Conn", ")", "readOp", "(", "c", "*", "control", ")", "error", "{", "br", ":=", "bufio", ".", "NewReaderSize", "(", "nc", ".", "conn", ",", "defaultBufSize", ")", "\n", "line", ",", "err", ":=", "br", ".", "ReadString", "(",...
// Read a control line and process the intended op.
[ "Read", "a", "control", "line", "and", "process", "the", "intended", "op", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1678-L1686
24,481
nats-io/go-nats
nats.go
parseControl
func parseControl(line string, c *control) { toks := strings.SplitN(line, _SPC_, 2) if len(toks) == 1 { c.op = strings.TrimSpace(toks[0]) c.args = _EMPTY_ } else if len(toks) == 2 { c.op, c.args = strings.TrimSpace(toks[0]), strings.TrimSpace(toks[1]) } else { c.op = _EMPTY_ } }
go
func parseControl(line string, c *control) { toks := strings.SplitN(line, _SPC_, 2) if len(toks) == 1 { c.op = strings.TrimSpace(toks[0]) c.args = _EMPTY_ } else if len(toks) == 2 { c.op, c.args = strings.TrimSpace(toks[0]), strings.TrimSpace(toks[1]) } else { c.op = _EMPTY_ } }
[ "func", "parseControl", "(", "line", "string", ",", "c", "*", "control", ")", "{", "toks", ":=", "strings", ".", "SplitN", "(", "line", ",", "_SPC_", ",", "2", ")", "\n", "if", "len", "(", "toks", ")", "==", "1", "{", "c", ".", "op", "=", "stri...
// Parse a control line from the server.
[ "Parse", "a", "control", "line", "from", "the", "server", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1689-L1699
24,482
nats-io/go-nats
nats.go
flushReconnectPendingItems
func (nc *Conn) flushReconnectPendingItems() { if nc.pending == nil { return } if nc.pending.Len() > 0 { nc.bw.Write(nc.pending.Bytes()) } }
go
func (nc *Conn) flushReconnectPendingItems() { if nc.pending == nil { return } if nc.pending.Len() > 0 { nc.bw.Write(nc.pending.Bytes()) } }
[ "func", "(", "nc", "*", "Conn", ")", "flushReconnectPendingItems", "(", ")", "{", "if", "nc", ".", "pending", "==", "nil", "{", "return", "\n", "}", "\n", "if", "nc", ".", "pending", ".", "Len", "(", ")", ">", "0", "{", "nc", ".", "bw", ".", "W...
// flushReconnectPending will push the pending items that were // gathered while we were in a RECONNECTING state to the socket.
[ "flushReconnectPending", "will", "push", "the", "pending", "items", "that", "were", "gathered", "while", "we", "were", "in", "a", "RECONNECTING", "state", "to", "the", "socket", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1703-L1710
24,483
nats-io/go-nats
nats.go
doReconnect
func (nc *Conn) doReconnect() { // We want to make sure we have the other watchers shutdown properly // here before we proceed past this point. nc.waitForExits() // FIXME(dlc) - We have an issue here if we have // outstanding flush points (pongs) and they were not // sent out, but are still in the pipe. // Hol...
go
func (nc *Conn) doReconnect() { // We want to make sure we have the other watchers shutdown properly // here before we proceed past this point. nc.waitForExits() // FIXME(dlc) - We have an issue here if we have // outstanding flush points (pongs) and they were not // sent out, but are still in the pipe. // Hol...
[ "func", "(", "nc", "*", "Conn", ")", "doReconnect", "(", ")", "{", "// We want to make sure we have the other watchers shutdown properly", "// here before we proceed past this point.", "nc", ".", "waitForExits", "(", ")", "\n\n", "// FIXME(dlc) - We have an issue here if we have"...
// Try to reconnect using the option parameters. // This function assumes we are allowed to reconnect.
[ "Try", "to", "reconnect", "using", "the", "option", "parameters", ".", "This", "function", "assumes", "we", "are", "allowed", "to", "reconnect", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1722-L1863
24,484
nats-io/go-nats
nats.go
processOpErr
func (nc *Conn) processOpErr(err error) { nc.mu.Lock() if nc.isConnecting() || nc.isClosed() || nc.isReconnecting() { nc.mu.Unlock() return } if nc.Opts.AllowReconnect && nc.status == CONNECTED { // Set our new status nc.status = RECONNECTING // Stop ping timer if set nc.stopPingTimer() if nc.conn !=...
go
func (nc *Conn) processOpErr(err error) { nc.mu.Lock() if nc.isConnecting() || nc.isClosed() || nc.isReconnecting() { nc.mu.Unlock() return } if nc.Opts.AllowReconnect && nc.status == CONNECTED { // Set our new status nc.status = RECONNECTING // Stop ping timer if set nc.stopPingTimer() if nc.conn !=...
[ "func", "(", "nc", "*", "Conn", ")", "processOpErr", "(", "err", "error", ")", "{", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "nc", ".", "isConnecting", "(", ")", "||", "nc", ".", "isClosed", "(", ")", "||", "nc", ".", "isReconnecting",...
// processOpErr handles errors from reading or parsing the protocol. // The lock should not be held entering this function.
[ "processOpErr", "handles", "errors", "from", "reading", "or", "parsing", "the", "protocol", ".", "The", "lock", "should", "not", "be", "held", "entering", "this", "function", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1867-L1898
24,485
nats-io/go-nats
nats.go
asyncCBDispatcher
func (ac *asyncCallbacksHandler) asyncCBDispatcher() { for { ac.mu.Lock() // Protect for spurious wakeups. We should get out of the // wait only if there is an element to pop from the list. for ac.head == nil { ac.cond.Wait() } cur := ac.head ac.head = cur.next if cur == ac.tail { ac.tail = nil ...
go
func (ac *asyncCallbacksHandler) asyncCBDispatcher() { for { ac.mu.Lock() // Protect for spurious wakeups. We should get out of the // wait only if there is an element to pop from the list. for ac.head == nil { ac.cond.Wait() } cur := ac.head ac.head = cur.next if cur == ac.tail { ac.tail = nil ...
[ "func", "(", "ac", "*", "asyncCallbacksHandler", ")", "asyncCBDispatcher", "(", ")", "{", "for", "{", "ac", ".", "mu", ".", "Lock", "(", ")", "\n", "// Protect for spurious wakeups. We should get out of the", "// wait only if there is an element to pop from the list.", "f...
// dispatch is responsible for calling any async callbacks
[ "dispatch", "is", "responsible", "for", "calling", "any", "async", "callbacks" ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1901-L1924
24,486
nats-io/go-nats
nats.go
pushOrClose
func (ac *asyncCallbacksHandler) pushOrClose(f func(), close bool) { ac.mu.Lock() defer ac.mu.Unlock() // Make sure that library is not calling push with nil function, // since this is used to notify the dispatcher that it should stop. if !close && f == nil { panic("pushing a nil callback") } cb := &asyncCB{f:...
go
func (ac *asyncCallbacksHandler) pushOrClose(f func(), close bool) { ac.mu.Lock() defer ac.mu.Unlock() // Make sure that library is not calling push with nil function, // since this is used to notify the dispatcher that it should stop. if !close && f == nil { panic("pushing a nil callback") } cb := &asyncCB{f:...
[ "func", "(", "ac", "*", "asyncCallbacksHandler", ")", "pushOrClose", "(", "f", "func", "(", ")", ",", "close", "bool", ")", "{", "ac", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "ac", ".", "mu", ".", "Unlock", "(", ")", "\n", "// Make sure th...
// Add the given function to the tail of the list and // signals the dispatcher.
[ "Add", "the", "given", "function", "to", "the", "tail", "of", "the", "list", "and", "signals", "the", "dispatcher", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L1939-L1959
24,487
nats-io/go-nats
nats.go
waitForMsgs
func (nc *Conn) waitForMsgs(s *Subscription) { var closed bool var delivered, max uint64 // Used to account for adjustments to sub.pBytes when we wrap back around. msgLen := -1 for { s.mu.Lock() // Do accounting for last msg delivered here so we only lock once // and drain state trips after callback has re...
go
func (nc *Conn) waitForMsgs(s *Subscription) { var closed bool var delivered, max uint64 // Used to account for adjustments to sub.pBytes when we wrap back around. msgLen := -1 for { s.mu.Lock() // Do accounting for last msg delivered here so we only lock once // and drain state trips after callback has re...
[ "func", "(", "nc", "*", "Conn", ")", "waitForMsgs", "(", "s", "*", "Subscription", ")", "{", "var", "closed", "bool", "\n", "var", "delivered", ",", "max", "uint64", "\n\n", "// Used to account for adjustments to sub.pBytes when we wrap back around.", "msgLen", ":="...
// waitForMsgs waits on the conditional shared with readLoop and processMsg. // It is used to deliver messages to asynchronous subscribers.
[ "waitForMsgs", "waits", "on", "the", "conditional", "shared", "with", "readLoop", "and", "processMsg", ".", "It", "is", "used", "to", "deliver", "messages", "to", "asynchronous", "subscribers", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2010-L2084
24,488
nats-io/go-nats
nats.go
processPermissionsViolation
func (nc *Conn) processPermissionsViolation(err string) { nc.mu.Lock() // create error here so we can pass it as a closure to the async cb dispatcher. e := errors.New("nats: " + err) nc.err = e if nc.Opts.AsyncErrorCB != nil { nc.ach.push(func() { nc.Opts.AsyncErrorCB(nc, nil, e) }) } nc.mu.Unlock() }
go
func (nc *Conn) processPermissionsViolation(err string) { nc.mu.Lock() // create error here so we can pass it as a closure to the async cb dispatcher. e := errors.New("nats: " + err) nc.err = e if nc.Opts.AsyncErrorCB != nil { nc.ach.push(func() { nc.Opts.AsyncErrorCB(nc, nil, e) }) } nc.mu.Unlock() }
[ "func", "(", "nc", "*", "Conn", ")", "processPermissionsViolation", "(", "err", "string", ")", "{", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "// create error here so we can pass it as a closure to the async cb dispatcher.", "e", ":=", "errors", ".", "New", "(...
// processPermissionsViolation is called when the server signals a subject // permissions violation on either publish or subscribe.
[ "processPermissionsViolation", "is", "called", "when", "the", "server", "signals", "a", "subject", "permissions", "violation", "on", "either", "publish", "or", "subscribe", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2193-L2202
24,489
nats-io/go-nats
nats.go
processAuthorizationViolation
func (nc *Conn) processAuthorizationViolation(err string) { nc.mu.Lock() nc.err = ErrAuthorization if nc.Opts.AsyncErrorCB != nil { nc.ach.push(func() { nc.Opts.AsyncErrorCB(nc, nil, ErrAuthorization) }) } nc.mu.Unlock() }
go
func (nc *Conn) processAuthorizationViolation(err string) { nc.mu.Lock() nc.err = ErrAuthorization if nc.Opts.AsyncErrorCB != nil { nc.ach.push(func() { nc.Opts.AsyncErrorCB(nc, nil, ErrAuthorization) }) } nc.mu.Unlock() }
[ "func", "(", "nc", "*", "Conn", ")", "processAuthorizationViolation", "(", "err", "string", ")", "{", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "nc", ".", "err", "=", "ErrAuthorization", "\n", "if", "nc", ".", "Opts", ".", "AsyncErrorCB", "!=", "...
// processAuthorizationViolation is called when the server signals a user // authorization violation.
[ "processAuthorizationViolation", "is", "called", "when", "the", "server", "signals", "a", "user", "authorization", "violation", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2206-L2213
24,490
nats-io/go-nats
nats.go
flusher
func (nc *Conn) flusher() { // Release the wait group defer nc.wg.Done() // snapshot the bw and conn since they can change from underneath of us. nc.mu.Lock() bw := nc.bw conn := nc.conn fch := nc.fch nc.mu.Unlock() if conn == nil || bw == nil { return } for { if _, ok := <-fch; !ok { return } ...
go
func (nc *Conn) flusher() { // Release the wait group defer nc.wg.Done() // snapshot the bw and conn since they can change from underneath of us. nc.mu.Lock() bw := nc.bw conn := nc.conn fch := nc.fch nc.mu.Unlock() if conn == nil || bw == nil { return } for { if _, ok := <-fch; !ok { return } ...
[ "func", "(", "nc", "*", "Conn", ")", "flusher", "(", ")", "{", "// Release the wait group", "defer", "nc", ".", "wg", ".", "Done", "(", ")", "\n\n", "// snapshot the bw and conn since they can change from underneath of us.", "nc", ".", "mu", ".", "Lock", "(", ")...
// flusher is a separate Go routine that will process flush requests for the write // bufio. This allows coalescing of writes to the underlying socket.
[ "flusher", "is", "a", "separate", "Go", "routine", "that", "will", "process", "flush", "requests", "for", "the", "write", "bufio", ".", "This", "allows", "coalescing", "of", "writes", "to", "the", "underlying", "socket", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2217-L2252
24,491
nats-io/go-nats
nats.go
processPong
func (nc *Conn) processPong() { var ch chan struct{} nc.mu.Lock() if len(nc.pongs) > 0 { ch = nc.pongs[0] nc.pongs = nc.pongs[1:] } nc.pout = 0 nc.mu.Unlock() if ch != nil { ch <- struct{}{} } }
go
func (nc *Conn) processPong() { var ch chan struct{} nc.mu.Lock() if len(nc.pongs) > 0 { ch = nc.pongs[0] nc.pongs = nc.pongs[1:] } nc.pout = 0 nc.mu.Unlock() if ch != nil { ch <- struct{}{} } }
[ "func", "(", "nc", "*", "Conn", ")", "processPong", "(", ")", "{", "var", "ch", "chan", "struct", "{", "}", "\n\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "if", "len", "(", "nc", ".", "pongs", ")", ">", "0", "{", "ch", "=", "nc", "."...
// processPong is used to process responses to the client's ping // messages. We use pings for the flush mechanism as well.
[ "processPong", "is", "used", "to", "process", "responses", "to", "the", "client", "s", "ping", "messages", ".", "We", "use", "pings", "for", "the", "flush", "mechanism", "as", "well", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2262-L2275
24,492
nats-io/go-nats
nats.go
processInfo
func (nc *Conn) processInfo(info string) error { if info == _EMPTY_ { return nil } ncInfo := serverInfo{} if err := json.Unmarshal([]byte(info), &ncInfo); err != nil { return err } // Copy content into connection's info structure. nc.info = ncInfo // The array could be empty/not present on initial connect,...
go
func (nc *Conn) processInfo(info string) error { if info == _EMPTY_ { return nil } ncInfo := serverInfo{} if err := json.Unmarshal([]byte(info), &ncInfo); err != nil { return err } // Copy content into connection's info structure. nc.info = ncInfo // The array could be empty/not present on initial connect,...
[ "func", "(", "nc", "*", "Conn", ")", "processInfo", "(", "info", "string", ")", "error", "{", "if", "info", "==", "_EMPTY_", "{", "return", "nil", "\n", "}", "\n", "ncInfo", ":=", "serverInfo", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmar...
// processInfo is used to parse the info messages sent // from the server. // This function may update the server pool.
[ "processInfo", "is", "used", "to", "parse", "the", "info", "messages", "sent", "from", "the", "server", ".", "This", "function", "may", "update", "the", "server", "pool", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2285-L2357
24,493
nats-io/go-nats
nats.go
processAsyncInfo
func (nc *Conn) processAsyncInfo(info []byte) { nc.mu.Lock() // Ignore errors, we will simply not update the server pool... nc.processInfo(string(info)) nc.mu.Unlock() }
go
func (nc *Conn) processAsyncInfo(info []byte) { nc.mu.Lock() // Ignore errors, we will simply not update the server pool... nc.processInfo(string(info)) nc.mu.Unlock() }
[ "func", "(", "nc", "*", "Conn", ")", "processAsyncInfo", "(", "info", "[", "]", "byte", ")", "{", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "// Ignore errors, we will simply not update the server pool...", "nc", ".", "processInfo", "(", "string", "(", "i...
// processAsyncInfo does the same than processInfo, but is called // from the parser. Calls processInfo under connection's lock // protection.
[ "processAsyncInfo", "does", "the", "same", "than", "processInfo", "but", "is", "called", "from", "the", "parser", ".", "Calls", "processInfo", "under", "connection", "s", "lock", "protection", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2362-L2367
24,494
nats-io/go-nats
nats.go
LastError
func (nc *Conn) LastError() error { if nc == nil { return ErrInvalidConnection } nc.mu.RLock() err := nc.err nc.mu.RUnlock() return err }
go
func (nc *Conn) LastError() error { if nc == nil { return ErrInvalidConnection } nc.mu.RLock() err := nc.err nc.mu.RUnlock() return err }
[ "func", "(", "nc", "*", "Conn", ")", "LastError", "(", ")", "error", "{", "if", "nc", "==", "nil", "{", "return", "ErrInvalidConnection", "\n", "}", "\n", "nc", ".", "mu", ".", "RLock", "(", ")", "\n", "err", ":=", "nc", ".", "err", "\n", "nc", ...
// LastError reports the last error encountered via the connection. // It can be used reliably within ClosedCB in order to find out reason // why connection was closed for example.
[ "LastError", "reports", "the", "last", "error", "encountered", "via", "the", "connection", ".", "It", "can", "be", "used", "reliably", "within", "ClosedCB", "in", "order", "to", "find", "out", "reason", "why", "connection", "was", "closed", "for", "example", ...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2372-L2380
24,495
nats-io/go-nats
nats.go
processErr
func (nc *Conn) processErr(ie string) { // Trim, remove quotes ne := normalizeErr(ie) // convert to lower case. e := strings.ToLower(ne) // FIXME(dlc) - process Slow Consumer signals special. if e == STALE_CONNECTION { nc.processOpErr(ErrStaleConnection) } else if strings.HasPrefix(e, PERMISSIONS_ERR) { nc....
go
func (nc *Conn) processErr(ie string) { // Trim, remove quotes ne := normalizeErr(ie) // convert to lower case. e := strings.ToLower(ne) // FIXME(dlc) - process Slow Consumer signals special. if e == STALE_CONNECTION { nc.processOpErr(ErrStaleConnection) } else if strings.HasPrefix(e, PERMISSIONS_ERR) { nc....
[ "func", "(", "nc", "*", "Conn", ")", "processErr", "(", "ie", "string", ")", "{", "// Trim, remove quotes", "ne", ":=", "normalizeErr", "(", "ie", ")", "\n", "// convert to lower case.", "e", ":=", "strings", ".", "ToLower", "(", "ne", ")", "\n\n", "// FIX...
// processErr processes any error messages from the server and // sets the connection's lastError.
[ "processErr", "processes", "any", "error", "messages", "from", "the", "server", "and", "sets", "the", "connection", "s", "lastError", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2384-L2403
24,496
nats-io/go-nats
nats.go
Publish
func (nc *Conn) Publish(subj string, data []byte) error { return nc.publish(subj, _EMPTY_, data) }
go
func (nc *Conn) Publish(subj string, data []byte) error { return nc.publish(subj, _EMPTY_, data) }
[ "func", "(", "nc", "*", "Conn", ")", "Publish", "(", "subj", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "return", "nc", ".", "publish", "(", "subj", ",", "_EMPTY_", ",", "data", ")", "\n", "}" ]
// Publish publishes the data argument to the given subject. The data // argument is left untouched and needs to be correctly interpreted on // the receiver.
[ "Publish", "publishes", "the", "data", "argument", "to", "the", "given", "subject", ".", "The", "data", "argument", "is", "left", "untouched", "and", "needs", "to", "be", "correctly", "interpreted", "on", "the", "receiver", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2419-L2421
24,497
nats-io/go-nats
nats.go
PublishMsg
func (nc *Conn) PublishMsg(m *Msg) error { if m == nil { return ErrInvalidMsg } return nc.publish(m.Subject, m.Reply, m.Data) }
go
func (nc *Conn) PublishMsg(m *Msg) error { if m == nil { return ErrInvalidMsg } return nc.publish(m.Subject, m.Reply, m.Data) }
[ "func", "(", "nc", "*", "Conn", ")", "PublishMsg", "(", "m", "*", "Msg", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "ErrInvalidMsg", "\n", "}", "\n", "return", "nc", ".", "publish", "(", "m", ".", "Subject", ",", "m", ".", "Reply",...
// PublishMsg publishes the Msg structure, which includes the // Subject, an optional Reply and an optional Data field.
[ "PublishMsg", "publishes", "the", "Msg", "structure", "which", "includes", "the", "Subject", "an", "optional", "Reply", "and", "an", "optional", "Data", "field", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2425-L2430
24,498
nats-io/go-nats
nats.go
publish
func (nc *Conn) publish(subj, reply string, data []byte) error { if nc == nil { return ErrInvalidConnection } if subj == "" { return ErrBadSubject } nc.mu.Lock() if nc.isClosed() { nc.mu.Unlock() return ErrConnectionClosed } if nc.isDrainingPubs() { nc.mu.Unlock() return ErrConnectionDraining } ...
go
func (nc *Conn) publish(subj, reply string, data []byte) error { if nc == nil { return ErrInvalidConnection } if subj == "" { return ErrBadSubject } nc.mu.Lock() if nc.isClosed() { nc.mu.Unlock() return ErrConnectionClosed } if nc.isDrainingPubs() { nc.mu.Unlock() return ErrConnectionDraining } ...
[ "func", "(", "nc", "*", "Conn", ")", "publish", "(", "subj", ",", "reply", "string", ",", "data", "[", "]", "byte", ")", "error", "{", "if", "nc", "==", "nil", "{", "return", "ErrInvalidConnection", "\n", "}", "\n", "if", "subj", "==", "\"", "\"", ...
// publish is the internal function to publish messages to a nats-server. // Sends a protocol data message by queuing into the bufio writer // and kicking the flush go routine. These writes should be protected.
[ "publish", "is", "the", "internal", "function", "to", "publish", "messages", "to", "a", "nats", "-", "server", ".", "Sends", "a", "protocol", "data", "message", "by", "queuing", "into", "the", "bufio", "writer", "and", "kicking", "the", "flush", "go", "rou...
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2445-L2531
24,499
nats-io/go-nats
nats.go
respHandler
func (nc *Conn) respHandler(m *Msg) { rt := respToken(m.Subject) nc.mu.Lock() // Just return if closed. if nc.isClosed() { nc.mu.Unlock() return } // Grab mch mch := nc.respMap[rt] // Delete the key regardless, one response only. // FIXME(dlc) - should we track responses past 1 // just statistics wise? ...
go
func (nc *Conn) respHandler(m *Msg) { rt := respToken(m.Subject) nc.mu.Lock() // Just return if closed. if nc.isClosed() { nc.mu.Unlock() return } // Grab mch mch := nc.respMap[rt] // Delete the key regardless, one response only. // FIXME(dlc) - should we track responses past 1 // just statistics wise? ...
[ "func", "(", "nc", "*", "Conn", ")", "respHandler", "(", "m", "*", "Msg", ")", "{", "rt", ":=", "respToken", "(", "m", ".", "Subject", ")", "\n\n", "nc", ".", "mu", ".", "Lock", "(", ")", "\n", "// Just return if closed.", "if", "nc", ".", "isClose...
// respHandler is the global response handler. It will look up // the appropriate channel based on the last token and place // the message on the channel if possible.
[ "respHandler", "is", "the", "global", "response", "handler", ".", "It", "will", "look", "up", "the", "appropriate", "channel", "based", "on", "the", "last", "token", "and", "place", "the", "message", "on", "the", "channel", "if", "possible", "." ]
36d30b0ba7aa260ae25b4f3d312b2a700106fd78
https://github.com/nats-io/go-nats/blob/36d30b0ba7aa260ae25b4f3d312b2a700106fd78/nats.go#L2536-L2562