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
26,600
google/seesaw
healthcheck/radius.go
String
func (rat radiusAttributeType) String() string { if name, ok := ratNames[rat]; ok { return name } return fmt.Sprintf("(unknown %d)", rat) }
go
func (rat radiusAttributeType) String() string { if name, ok := ratNames[rat]; ok { return name } return fmt.Sprintf("(unknown %d)", rat) }
[ "func", "(", "rat", "radiusAttributeType", ")", "String", "(", ")", "string", "{", "if", "name", ",", "ok", ":=", "ratNames", "[", "rat", "]", ";", "ok", "{", "return", "name", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",",...
// String returns the string representation of a RADIUS attribute type.
[ "String", "returns", "the", "string", "representation", "of", "a", "RADIUS", "attribute", "type", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/radius.go#L144-L149
26,601
google/seesaw
healthcheck/radius.go
radiusPassword
func radiusPassword(passwd, secret string, authenticator *radiusAuthenticator) []byte { const blockSize = 16 length := (len(passwd) + 0xf) &^ 0xf if length > 128 { length = 128 } blocks := make([]byte, length) copy(blocks, []byte(passwd)) for i := 0; i < length; i += blockSize { hash := md5.New() hash.Writ...
go
func radiusPassword(passwd, secret string, authenticator *radiusAuthenticator) []byte { const blockSize = 16 length := (len(passwd) + 0xf) &^ 0xf if length > 128 { length = 128 } blocks := make([]byte, length) copy(blocks, []byte(passwd)) for i := 0; i < length; i += blockSize { hash := md5.New() hash.Writ...
[ "func", "radiusPassword", "(", "passwd", ",", "secret", "string", ",", "authenticator", "*", "radiusAuthenticator", ")", "[", "]", "byte", "{", "const", "blockSize", "=", "16", "\n", "length", ":=", "(", "len", "(", "passwd", ")", "+", "0xf", ")", "&^", ...
// radiusPassword encodes a password using the algorithm described in RFC2865 // section 5.2.
[ "radiusPassword", "encodes", "a", "password", "using", "the", "algorithm", "described", "in", "RFC2865", "section", "5", ".", "2", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/radius.go#L241-L263
26,602
google/seesaw
healthcheck/radius.go
responseAuthenticator
func responseAuthenticator(rp *radiusPacket, requestAuthenticator *radiusAuthenticator, secret string) (*radiusAuthenticator, error) { hash := md5.New() hash.Write([]byte{byte(rp.Code), byte(rp.Identifier)}) if err := binary.Write(hash, binary.BigEndian, rp.Length); err != nil { return nil, err } hash.Write(requ...
go
func responseAuthenticator(rp *radiusPacket, requestAuthenticator *radiusAuthenticator, secret string) (*radiusAuthenticator, error) { hash := md5.New() hash.Write([]byte{byte(rp.Code), byte(rp.Identifier)}) if err := binary.Write(hash, binary.BigEndian, rp.Length); err != nil { return nil, err } hash.Write(requ...
[ "func", "responseAuthenticator", "(", "rp", "*", "radiusPacket", ",", "requestAuthenticator", "*", "radiusAuthenticator", ",", "secret", "string", ")", "(", "*", "radiusAuthenticator", ",", "error", ")", "{", "hash", ":=", "md5", ".", "New", "(", ")", "\n", ...
// responseAuthenticator calculates the response authenticator for a RADIUS // response packet, as per RFC2865 section 3.
[ "responseAuthenticator", "calculates", "the", "response", "authenticator", "for", "a", "RADIUS", "response", "packet", "as", "per", "RFC2865", "section", "3", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/radius.go#L267-L282
26,603
google/seesaw
healthcheck/radius.go
NewRADIUSChecker
func NewRADIUSChecker(ip net.IP, port int) *RADIUSChecker { return &RADIUSChecker{ Target: Target{ IP: ip, Port: port, Proto: seesaw.IPProtoUDP, }, Response: "accept", } }
go
func NewRADIUSChecker(ip net.IP, port int) *RADIUSChecker { return &RADIUSChecker{ Target: Target{ IP: ip, Port: port, Proto: seesaw.IPProtoUDP, }, Response: "accept", } }
[ "func", "NewRADIUSChecker", "(", "ip", "net", ".", "IP", ",", "port", "int", ")", "*", "RADIUSChecker", "{", "return", "&", "RADIUSChecker", "{", "Target", ":", "Target", "{", "IP", ":", "ip", ",", "Port", ":", "port", ",", "Proto", ":", "seesaw", "....
// NewRADIUSChecker returns an initialised RADIUSChecker.
[ "NewRADIUSChecker", "returns", "an", "initialised", "RADIUSChecker", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/radius.go#L294-L303
26,604
google/seesaw
engine/config/types.go
NewCluster
func NewCluster(site string) *Cluster { return &Cluster{ Site: site, BGPPeers: make(map[string]*seesaw.Host), Nodes: make(map[string]*seesaw.Node), VIPSubnets: make(map[string]*net.IPNet), Vservers: make(map[string]*Vserver), VLANs: make(map[uint16]*seesaw.VLAN), Status: seesaw.Config...
go
func NewCluster(site string) *Cluster { return &Cluster{ Site: site, BGPPeers: make(map[string]*seesaw.Host), Nodes: make(map[string]*seesaw.Node), VIPSubnets: make(map[string]*net.IPNet), Vservers: make(map[string]*Vserver), VLANs: make(map[uint16]*seesaw.VLAN), Status: seesaw.Config...
[ "func", "NewCluster", "(", "site", "string", ")", "*", "Cluster", "{", "return", "&", "Cluster", "{", "Site", ":", "site", ",", "BGPPeers", ":", "make", "(", "map", "[", "string", "]", "*", "seesaw", ".", "Host", ")", ",", "Nodes", ":", "make", "("...
// NewCluster returns an initialised Cluster structure.
[ "NewCluster", "returns", "an", "initialised", "Cluster", "structure", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L45-L58
26,605
google/seesaw
engine/config/types.go
AddBGPPeer
func (c *Cluster) AddBGPPeer(peer *seesaw.Host) error { key := peer.Hostname if _, ok := c.BGPPeers[key]; ok { return fmt.Errorf("Cluster %q already contains peer %q", c.Site, key) } c.BGPPeers[key] = peer return nil }
go
func (c *Cluster) AddBGPPeer(peer *seesaw.Host) error { key := peer.Hostname if _, ok := c.BGPPeers[key]; ok { return fmt.Errorf("Cluster %q already contains peer %q", c.Site, key) } c.BGPPeers[key] = peer return nil }
[ "func", "(", "c", "*", "Cluster", ")", "AddBGPPeer", "(", "peer", "*", "seesaw", ".", "Host", ")", "error", "{", "key", ":=", "peer", ".", "Hostname", "\n", "if", "_", ",", "ok", ":=", "c", ".", "BGPPeers", "[", "key", "]", ";", "ok", "{", "ret...
// AddBGPPeer adds a BGP peer to a Seesaw Cluster.
[ "AddBGPPeer", "adds", "a", "BGP", "peer", "to", "a", "Seesaw", "Cluster", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L61-L68
26,606
google/seesaw
engine/config/types.go
AddNode
func (c *Cluster) AddNode(node *seesaw.Node) error { key := node.Key() if _, ok := c.Nodes[key]; ok { return fmt.Errorf("Cluster %q already contains Node %q", c.Site, key) } c.Nodes[key] = node return nil }
go
func (c *Cluster) AddNode(node *seesaw.Node) error { key := node.Key() if _, ok := c.Nodes[key]; ok { return fmt.Errorf("Cluster %q already contains Node %q", c.Site, key) } c.Nodes[key] = node return nil }
[ "func", "(", "c", "*", "Cluster", ")", "AddNode", "(", "node", "*", "seesaw", ".", "Node", ")", "error", "{", "key", ":=", "node", ".", "Key", "(", ")", "\n", "if", "_", ",", "ok", ":=", "c", ".", "Nodes", "[", "key", "]", ";", "ok", "{", "...
// AddNode adds a Seesaw Node to a Seesaw Cluster.
[ "AddNode", "adds", "a", "Seesaw", "Node", "to", "a", "Seesaw", "Cluster", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L71-L78
26,607
google/seesaw
engine/config/types.go
AddVIPSubnet
func (c *Cluster) AddVIPSubnet(subnet *net.IPNet) error { key := subnet.String() if _, ok := c.VIPSubnets[key]; ok { return fmt.Errorf("Cluster %q already contains VIP Subnet %q", c.Site, key) } c.VIPSubnets[key] = subnet return nil }
go
func (c *Cluster) AddVIPSubnet(subnet *net.IPNet) error { key := subnet.String() if _, ok := c.VIPSubnets[key]; ok { return fmt.Errorf("Cluster %q already contains VIP Subnet %q", c.Site, key) } c.VIPSubnets[key] = subnet return nil }
[ "func", "(", "c", "*", "Cluster", ")", "AddVIPSubnet", "(", "subnet", "*", "net", ".", "IPNet", ")", "error", "{", "key", ":=", "subnet", ".", "String", "(", ")", "\n", "if", "_", ",", "ok", ":=", "c", ".", "VIPSubnets", "[", "key", "]", ";", "...
// AddVIPSubnet adds a VIP Subnet to a Seesaw Cluster.
[ "AddVIPSubnet", "adds", "a", "VIP", "Subnet", "to", "a", "Seesaw", "Cluster", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L81-L88
26,608
google/seesaw
engine/config/types.go
AddVserver
func (c *Cluster) AddVserver(vserver *Vserver) error { key := vserver.Key() if _, ok := c.Vservers[key]; ok { return fmt.Errorf("Cluster %q already contains Vserver %q", c.Site, key) } c.Vservers[key] = vserver return nil }
go
func (c *Cluster) AddVserver(vserver *Vserver) error { key := vserver.Key() if _, ok := c.Vservers[key]; ok { return fmt.Errorf("Cluster %q already contains Vserver %q", c.Site, key) } c.Vservers[key] = vserver return nil }
[ "func", "(", "c", "*", "Cluster", ")", "AddVserver", "(", "vserver", "*", "Vserver", ")", "error", "{", "key", ":=", "vserver", ".", "Key", "(", ")", "\n", "if", "_", ",", "ok", ":=", "c", ".", "Vservers", "[", "key", "]", ";", "ok", "{", "retu...
// AddVserver adds a Vserver to a Seesaw Cluster.
[ "AddVserver", "adds", "a", "Vserver", "to", "a", "Seesaw", "Cluster", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L91-L98
26,609
google/seesaw
engine/config/types.go
AddVLAN
func (c *Cluster) AddVLAN(vlan *seesaw.VLAN) error { key := vlan.Key() if _, ok := c.VLANs[key]; ok { return fmt.Errorf("Cluster %q already contains VLAN %q", c.Site, key) } c.VLANs[key] = vlan return nil }
go
func (c *Cluster) AddVLAN(vlan *seesaw.VLAN) error { key := vlan.Key() if _, ok := c.VLANs[key]; ok { return fmt.Errorf("Cluster %q already contains VLAN %q", c.Site, key) } c.VLANs[key] = vlan return nil }
[ "func", "(", "c", "*", "Cluster", ")", "AddVLAN", "(", "vlan", "*", "seesaw", ".", "VLAN", ")", "error", "{", "key", ":=", "vlan", ".", "Key", "(", ")", "\n", "if", "_", ",", "ok", ":=", "c", ".", "VLANs", "[", "key", "]", ";", "ok", "{", "...
// AddVLAN adds a VLAN to a Seesaw Cluster.
[ "AddVLAN", "adds", "a", "VLAN", "to", "a", "Seesaw", "Cluster", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L101-L108
26,610
google/seesaw
engine/config/types.go
Equal
func (c *Cluster) Equal(other *Cluster) bool { return reflect.DeepEqual(c, other) }
go
func (c *Cluster) Equal(other *Cluster) bool { return reflect.DeepEqual(c, other) }
[ "func", "(", "c", "*", "Cluster", ")", "Equal", "(", "other", "*", "Cluster", ")", "bool", "{", "return", "reflect", ".", "DeepEqual", "(", "c", ",", "other", ")", "\n", "}" ]
// Equal reports whether this cluster is equal to the given cluster.
[ "Equal", "reports", "whether", "this", "cluster", "is", "equal", "to", "the", "given", "cluster", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L111-L113
26,611
google/seesaw
engine/config/types.go
NewVserver
func NewVserver(name string, host seesaw.Host) *Vserver { return &Vserver{ Name: name, Host: host, Entries: make(map[string]*VserverEntry), Backends: make(map[string]*seesaw.Backend), Healthchecks: make(map[string]*Healthcheck), VIPs: make(map[string]*seesaw.VIP), Warning...
go
func NewVserver(name string, host seesaw.Host) *Vserver { return &Vserver{ Name: name, Host: host, Entries: make(map[string]*VserverEntry), Backends: make(map[string]*seesaw.Backend), Healthchecks: make(map[string]*Healthcheck), VIPs: make(map[string]*seesaw.VIP), Warning...
[ "func", "NewVserver", "(", "name", "string", ",", "host", "seesaw", ".", "Host", ")", "*", "Vserver", "{", "return", "&", "Vserver", "{", "Name", ":", "name", ",", "Host", ":", "host", ",", "Entries", ":", "make", "(", "map", "[", "string", "]", "*...
// NewVserver creates a new, initialised Vserver structure.
[ "NewVserver", "creates", "a", "new", "initialised", "Vserver", "structure", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L129-L139
26,612
google/seesaw
engine/config/types.go
AddVserverEntry
func (v *Vserver) AddVserverEntry(e *VserverEntry) error { key := e.Key() if _, ok := v.Entries[key]; ok { return fmt.Errorf("Vserver %q already contains VserverEntry %q", v.Name, key) } v.Entries[key] = e return nil }
go
func (v *Vserver) AddVserverEntry(e *VserverEntry) error { key := e.Key() if _, ok := v.Entries[key]; ok { return fmt.Errorf("Vserver %q already contains VserverEntry %q", v.Name, key) } v.Entries[key] = e return nil }
[ "func", "(", "v", "*", "Vserver", ")", "AddVserverEntry", "(", "e", "*", "VserverEntry", ")", "error", "{", "key", ":=", "e", ".", "Key", "(", ")", "\n", "if", "_", ",", "ok", ":=", "v", ".", "Entries", "[", "key", "]", ";", "ok", "{", "return"...
// AddVserverEntry adds an VserverEntry to a Vserver.
[ "AddVserverEntry", "adds", "an", "VserverEntry", "to", "a", "Vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L147-L154
26,613
google/seesaw
engine/config/types.go
AddBackend
func (v *Vserver) AddBackend(backend *seesaw.Backend) error { key := backend.Key() if _, ok := v.Backends[key]; ok { return fmt.Errorf("Vserver %q already contains Backend %q", v.Name, key) } v.Backends[key] = backend return nil }
go
func (v *Vserver) AddBackend(backend *seesaw.Backend) error { key := backend.Key() if _, ok := v.Backends[key]; ok { return fmt.Errorf("Vserver %q already contains Backend %q", v.Name, key) } v.Backends[key] = backend return nil }
[ "func", "(", "v", "*", "Vserver", ")", "AddBackend", "(", "backend", "*", "seesaw", ".", "Backend", ")", "error", "{", "key", ":=", "backend", ".", "Key", "(", ")", "\n", "if", "_", ",", "ok", ":=", "v", ".", "Backends", "[", "key", "]", ";", "...
// AddBackend adds a Backend to a Vserver.
[ "AddBackend", "adds", "a", "Backend", "to", "a", "Vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L157-L164
26,614
google/seesaw
engine/config/types.go
AddHealthcheck
func (v *Vserver) AddHealthcheck(h *Healthcheck) error { key := h.Key() if _, ok := v.Healthchecks[key]; ok { return fmt.Errorf("Vserver %q already contains Healthcheck %q", v.Name, key) } v.Healthchecks[key] = h return nil }
go
func (v *Vserver) AddHealthcheck(h *Healthcheck) error { key := h.Key() if _, ok := v.Healthchecks[key]; ok { return fmt.Errorf("Vserver %q already contains Healthcheck %q", v.Name, key) } v.Healthchecks[key] = h return nil }
[ "func", "(", "v", "*", "Vserver", ")", "AddHealthcheck", "(", "h", "*", "Healthcheck", ")", "error", "{", "key", ":=", "h", ".", "Key", "(", ")", "\n", "if", "_", ",", "ok", ":=", "v", ".", "Healthchecks", "[", "key", "]", ";", "ok", "{", "retu...
// AddHealthcheck adds a Healthcheck to a Vserver.
[ "AddHealthcheck", "adds", "a", "Healthcheck", "to", "a", "Vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L167-L174
26,615
google/seesaw
engine/config/types.go
AddVIP
func (v *Vserver) AddVIP(vip *seesaw.VIP) error { key := vip.String() if _, ok := v.VIPs[key]; ok { return fmt.Errorf("Vserver %q already contains VIP %q", v.Name, key) } v.VIPs[key] = vip return nil }
go
func (v *Vserver) AddVIP(vip *seesaw.VIP) error { key := vip.String() if _, ok := v.VIPs[key]; ok { return fmt.Errorf("Vserver %q already contains VIP %q", v.Name, key) } v.VIPs[key] = vip return nil }
[ "func", "(", "v", "*", "Vserver", ")", "AddVIP", "(", "vip", "*", "seesaw", ".", "VIP", ")", "error", "{", "key", ":=", "vip", ".", "String", "(", ")", "\n", "if", "_", ",", "ok", ":=", "v", ".", "VIPs", "[", "key", "]", ";", "ok", "{", "re...
// AddVIP adds a VIP to a Vserver.
[ "AddVIP", "adds", "a", "VIP", "to", "a", "Vserver", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L177-L184
26,616
google/seesaw
engine/config/types.go
NewVserverEntry
func NewVserverEntry(port uint16, proto seesaw.IPProto) *VserverEntry { return &VserverEntry{ Port: port, Proto: proto, Healthchecks: make(map[string]*Healthcheck), } }
go
func NewVserverEntry(port uint16, proto seesaw.IPProto) *VserverEntry { return &VserverEntry{ Port: port, Proto: proto, Healthchecks: make(map[string]*Healthcheck), } }
[ "func", "NewVserverEntry", "(", "port", "uint16", ",", "proto", "seesaw", ".", "IPProto", ")", "*", "VserverEntry", "{", "return", "&", "VserverEntry", "{", "Port", ":", "port", ",", "Proto", ":", "proto", ",", "Healthchecks", ":", "make", "(", "map", "[...
// NewVserverEntry creates a new, initialised VserverEntry structure.
[ "NewVserverEntry", "creates", "a", "new", "initialised", "VserverEntry", "structure", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L203-L209
26,617
google/seesaw
engine/config/types.go
Key
func (v *VserverEntry) Key() string { return fmt.Sprintf("%d/%s", v.Port, v.Proto) }
go
func (v *VserverEntry) Key() string { return fmt.Sprintf("%d/%s", v.Port, v.Proto) }
[ "func", "(", "v", "*", "VserverEntry", ")", "Key", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ".", "Port", ",", "v", ".", "Proto", ")", "\n", "}" ]
// Key returns the unique identifier for a VserverEntry.
[ "Key", "returns", "the", "unique", "identifier", "for", "a", "VserverEntry", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L222-L224
26,618
google/seesaw
engine/config/types.go
Snapshot
func (v *VserverEntry) Snapshot() *seesaw.VserverEntry { return &seesaw.VserverEntry{ Port: v.Port, Proto: v.Proto, Scheduler: v.Scheduler, Mode: v.Mode, Persistence: v.Persistence, OnePacket: v.OnePacket, HighWatermark: v.HighWatermark, LowWatermark: v.LowWatermark...
go
func (v *VserverEntry) Snapshot() *seesaw.VserverEntry { return &seesaw.VserverEntry{ Port: v.Port, Proto: v.Proto, Scheduler: v.Scheduler, Mode: v.Mode, Persistence: v.Persistence, OnePacket: v.OnePacket, HighWatermark: v.HighWatermark, LowWatermark: v.LowWatermark...
[ "func", "(", "v", "*", "VserverEntry", ")", "Snapshot", "(", ")", "*", "seesaw", ".", "VserverEntry", "{", "return", "&", "seesaw", ".", "VserverEntry", "{", "Port", ":", "v", ".", "Port", ",", "Proto", ":", "v", ".", "Proto", ",", "Scheduler", ":", ...
// Snapshot returns a snapshot for a VserverEntry.
[ "Snapshot", "returns", "a", "snapshot", "for", "a", "VserverEntry", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L227-L240
26,619
google/seesaw
engine/config/types.go
NewHealthcheck
func NewHealthcheck(m seesaw.HealthcheckMode, t seesaw.HealthcheckType, port uint16) *Healthcheck { return &Healthcheck{ Mode: m, Type: t, Port: port, } }
go
func NewHealthcheck(m seesaw.HealthcheckMode, t seesaw.HealthcheckType, port uint16) *Healthcheck { return &Healthcheck{ Mode: m, Type: t, Port: port, } }
[ "func", "NewHealthcheck", "(", "m", "seesaw", ".", "HealthcheckMode", ",", "t", "seesaw", ".", "HealthcheckType", ",", "port", "uint16", ")", "*", "Healthcheck", "{", "return", "&", "Healthcheck", "{", "Mode", ":", "m", ",", "Type", ":", "t", ",", "Port"...
// NewHealthcheck creates a new, initialised Healthcheck structure.
[ "NewHealthcheck", "creates", "a", "new", "initialised", "Healthcheck", "structure", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/config/types.go#L261-L267
26,620
google/seesaw
ncc/bgp.go
quaggaBGP
func quaggaBGP(asn uint32) (*quagga.BGP, error) { bgp := quagga.NewBGP("", asn) if err := bgp.Dial(); err != nil { return nil, err } if err := bgp.Enable(); err != nil { bgp.Close() return nil, err } return bgp, nil }
go
func quaggaBGP(asn uint32) (*quagga.BGP, error) { bgp := quagga.NewBGP("", asn) if err := bgp.Dial(); err != nil { return nil, err } if err := bgp.Enable(); err != nil { bgp.Close() return nil, err } return bgp, nil }
[ "func", "quaggaBGP", "(", "asn", "uint32", ")", "(", "*", "quagga", ".", "BGP", ",", "error", ")", "{", "bgp", ":=", "quagga", ".", "NewBGP", "(", "\"", "\"", ",", "asn", ")", "\n", "if", "err", ":=", "bgp", ".", "Dial", "(", ")", ";", "err", ...
// quaggaBGP establishes a connection with the Quagga BGP daemon.
[ "quaggaBGP", "establishes", "a", "connection", "with", "the", "Quagga", "BGP", "daemon", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/bgp.go#L36-L46
26,621
google/seesaw
ncc/bgp.go
BGPConfig
func (ncc *SeesawNCC) BGPConfig(unused int, cfg *ncctypes.BGPConfig) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() bgpCfg, err := bgp.Configuration() if err != nil { return err } if cfg != nil { cfg.Config = bgpCfg } return nil }
go
func (ncc *SeesawNCC) BGPConfig(unused int, cfg *ncctypes.BGPConfig) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() bgpCfg, err := bgp.Configuration() if err != nil { return err } if cfg != nil { cfg.Config = bgpCfg } return nil }
[ "func", "(", "ncc", "*", "SeesawNCC", ")", "BGPConfig", "(", "unused", "int", ",", "cfg", "*", "ncctypes", ".", "BGPConfig", ")", "error", "{", "bgp", ",", "err", ":=", "quaggaBGP", "(", "seesawASN", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// BGPConfig returns the current configuration for the Quagga BGP daemon.
[ "BGPConfig", "returns", "the", "current", "configuration", "for", "the", "Quagga", "BGP", "daemon", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/bgp.go#L49-L63
26,622
google/seesaw
ncc/bgp.go
BGPNeighbors
func (ncc *SeesawNCC) BGPNeighbors(unused int, neighbors *ncctypes.BGPNeighbors) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() bgpNeighbors, err := bgp.Neighbors() if err != nil { return err } if neighbors != nil { neighbors.Neighbors = bgpNeighbors } return nil...
go
func (ncc *SeesawNCC) BGPNeighbors(unused int, neighbors *ncctypes.BGPNeighbors) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() bgpNeighbors, err := bgp.Neighbors() if err != nil { return err } if neighbors != nil { neighbors.Neighbors = bgpNeighbors } return nil...
[ "func", "(", "ncc", "*", "SeesawNCC", ")", "BGPNeighbors", "(", "unused", "int", ",", "neighbors", "*", "ncctypes", ".", "BGPNeighbors", ")", "error", "{", "bgp", ",", "err", ":=", "quaggaBGP", "(", "seesawASN", ")", "\n", "if", "err", "!=", "nil", "{"...
// BGPNeighbors returns the current BGP neighbors for the Quagga BGP daemon.
[ "BGPNeighbors", "returns", "the", "current", "BGP", "neighbors", "for", "the", "Quagga", "BGP", "daemon", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/bgp.go#L66-L80
26,623
google/seesaw
ncc/bgp.go
hostMask
func hostMask(ip net.IP) net.IPMask { var hl int if ip.To4() != nil { hl = net.IPv4len * 8 } else { hl = net.IPv6len * 8 } return net.CIDRMask(hl, hl) }
go
func hostMask(ip net.IP) net.IPMask { var hl int if ip.To4() != nil { hl = net.IPv4len * 8 } else { hl = net.IPv6len * 8 } return net.CIDRMask(hl, hl) }
[ "func", "hostMask", "(", "ip", "net", ".", "IP", ")", "net", ".", "IPMask", "{", "var", "hl", "int", "\n", "if", "ip", ".", "To4", "(", ")", "!=", "nil", "{", "hl", "=", "net", ".", "IPv4len", "*", "8", "\n", "}", "else", "{", "hl", "=", "n...
// hostMask returns an IP mask that corresponds with a host prefix.
[ "hostMask", "returns", "an", "IP", "mask", "that", "corresponds", "with", "a", "host", "prefix", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/bgp.go#L83-L91
26,624
google/seesaw
ncc/bgp.go
BGPWithdrawAll
func (ncc *SeesawNCC) BGPWithdrawAll(unused int, reply *int) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() bgpCfg, err := bgp.Configuration() if err != nil { return err } // Find the network statements within the router bgp section. bgpStr := fmt.Sprintf("router ...
go
func (ncc *SeesawNCC) BGPWithdrawAll(unused int, reply *int) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() bgpCfg, err := bgp.Configuration() if err != nil { return err } // Find the network statements within the router bgp section. bgpStr := fmt.Sprintf("router ...
[ "func", "(", "ncc", "*", "SeesawNCC", ")", "BGPWithdrawAll", "(", "unused", "int", ",", "reply", "*", "int", ")", "error", "{", "bgp", ",", "err", ":=", "quaggaBGP", "(", "seesawASN", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", ...
// BGPWithdrawAll removes all network advertisements from the Quagga BGP daemon.
[ "BGPWithdrawAll", "removes", "all", "network", "advertisements", "from", "the", "Quagga", "BGP", "daemon", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/bgp.go#L94-L134
26,625
google/seesaw
ncc/bgp.go
BGPAdvertiseVIP
func (ncc *SeesawNCC) BGPAdvertiseVIP(vip net.IP, unused *int) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() return bgp.Advertise(&net.IPNet{IP: vip, Mask: hostMask(vip)}) }
go
func (ncc *SeesawNCC) BGPAdvertiseVIP(vip net.IP, unused *int) error { bgp, err := quaggaBGP(seesawASN) if err != nil { return err } defer bgp.Close() return bgp.Advertise(&net.IPNet{IP: vip, Mask: hostMask(vip)}) }
[ "func", "(", "ncc", "*", "SeesawNCC", ")", "BGPAdvertiseVIP", "(", "vip", "net", ".", "IP", ",", "unused", "*", "int", ")", "error", "{", "bgp", ",", "err", ":=", "quaggaBGP", "(", "seesawASN", ")", "\n", "if", "err", "!=", "nil", "{", "return", "e...
// BGPAdvertiseVIP requests the Quagga BGP daemon to advertise the given VIP.
[ "BGPAdvertiseVIP", "requests", "the", "Quagga", "BGP", "daemon", "to", "advertise", "the", "given", "VIP", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/ncc/bgp.go#L137-L144
26,626
google/seesaw
engine/ha.go
newHAManager
func newHAManager(engine *Engine, timeout time.Duration) *haManager { now := time.Now() return &haManager{ engine: engine, status: seesaw.HAStatus{ LastUpdate: now, Since: now, State: seesaw.HAUnknown, }, timeout: timeout, stateChan: make(chan seesaw.HAState, 1), statusChan: make(ch...
go
func newHAManager(engine *Engine, timeout time.Duration) *haManager { now := time.Now() return &haManager{ engine: engine, status: seesaw.HAStatus{ LastUpdate: now, Since: now, State: seesaw.HAUnknown, }, timeout: timeout, stateChan: make(chan seesaw.HAState, 1), statusChan: make(ch...
[ "func", "newHAManager", "(", "engine", "*", "Engine", ",", "timeout", "time", ".", "Duration", ")", "*", "haManager", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "return", "&", "haManager", "{", "engine", ":", "engine", ",", "status", ":", ...
// newHAManager creates a new haManager with the given HA state timeout.
[ "newHAManager", "creates", "a", "new", "haManager", "with", "the", "given", "HA", "state", "timeout", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L45-L58
26,627
google/seesaw
engine/ha.go
state
func (h *haManager) state() seesaw.HAState { h.statusLock.RLock() defer h.statusLock.RUnlock() return h.status.State }
go
func (h *haManager) state() seesaw.HAState { h.statusLock.RLock() defer h.statusLock.RUnlock() return h.status.State }
[ "func", "(", "h", "*", "haManager", ")", "state", "(", ")", "seesaw", ".", "HAState", "{", "h", ".", "statusLock", ".", "RLock", "(", ")", "\n", "defer", "h", ".", "statusLock", ".", "RUnlock", "(", ")", "\n", "return", "h", ".", "status", ".", "...
// state returns the current HA state known by the engine.
[ "state", "returns", "the", "current", "HA", "state", "known", "by", "the", "engine", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L61-L65
26,628
google/seesaw
engine/ha.go
enable
func (h *haManager) enable() { if h.state() == seesaw.HADisabled { h.setState(seesaw.HAUnknown) } }
go
func (h *haManager) enable() { if h.state() == seesaw.HADisabled { h.setState(seesaw.HAUnknown) } }
[ "func", "(", "h", "*", "haManager", ")", "enable", "(", ")", "{", "if", "h", ".", "state", "(", ")", "==", "seesaw", ".", "HADisabled", "{", "h", ".", "setState", "(", "seesaw", ".", "HAUnknown", ")", "\n", "}", "\n", "}" ]
// enable enables HA peering for the node on which the engine is running.
[ "enable", "enables", "HA", "peering", "for", "the", "node", "on", "which", "the", "engine", "is", "running", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L68-L72
26,629
google/seesaw
engine/ha.go
failover
func (h *haManager) failover() bool { h.failoverLock.Lock() pending := h.failoverPending h.failoverPending = false h.failoverLock.Unlock() return pending }
go
func (h *haManager) failover() bool { h.failoverLock.Lock() pending := h.failoverPending h.failoverPending = false h.failoverLock.Unlock() return pending }
[ "func", "(", "h", "*", "haManager", ")", "failover", "(", ")", "bool", "{", "h", ".", "failoverLock", ".", "Lock", "(", ")", "\n", "pending", ":=", "h", ".", "failoverPending", "\n", "h", ".", "failoverPending", "=", "false", "\n", "h", ".", "failove...
// failover returns true if the HA component should relinquish master state.
[ "failover", "returns", "true", "if", "the", "HA", "component", "should", "relinquish", "master", "state", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L80-L86
26,630
google/seesaw
engine/ha.go
requestFailover
func (h *haManager) requestFailover(peer bool) error { state := h.state() if state == seesaw.HAMaster { h.failoverLock.Lock() defer h.failoverLock.Unlock() if h.failoverPending { return fmt.Errorf("Failover request already pending") } h.failoverPending = true return nil } if peer { return fmt.Erro...
go
func (h *haManager) requestFailover(peer bool) error { state := h.state() if state == seesaw.HAMaster { h.failoverLock.Lock() defer h.failoverLock.Unlock() if h.failoverPending { return fmt.Errorf("Failover request already pending") } h.failoverPending = true return nil } if peer { return fmt.Erro...
[ "func", "(", "h", "*", "haManager", ")", "requestFailover", "(", "peer", "bool", ")", "error", "{", "state", ":=", "h", ".", "state", "(", ")", "\n", "if", "state", "==", "seesaw", ".", "HAMaster", "{", "h", ".", "failoverLock", ".", "Lock", "(", "...
// requestFailover requests the node to initiate a failover.
[ "requestFailover", "requests", "the", "node", "to", "initiate", "a", "failover", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L89-L110
26,631
google/seesaw
engine/ha.go
setState
func (h *haManager) setState(s seesaw.HAState) { state := h.state() if state == seesaw.HADisabled && s != seesaw.HAUnknown { log.Warningf("Invalid HA state transition %v -> %v", state, s) return } if state != s { log.Infof("HA state transition %v -> %v starting", state, s) if s == seesaw.HAMaster { h.e...
go
func (h *haManager) setState(s seesaw.HAState) { state := h.state() if state == seesaw.HADisabled && s != seesaw.HAUnknown { log.Warningf("Invalid HA state transition %v -> %v", state, s) return } if state != s { log.Infof("HA state transition %v -> %v starting", state, s) if s == seesaw.HAMaster { h.e...
[ "func", "(", "h", "*", "haManager", ")", "setState", "(", "s", "seesaw", ".", "HAState", ")", "{", "state", ":=", "h", ".", "state", "(", ")", "\n\n", "if", "state", "==", "seesaw", ".", "HADisabled", "&&", "s", "!=", "seesaw", ".", "HAUnknown", "{...
// setState sets the HAState of the engine and dispatches events when the state // changes.
[ "setState", "sets", "the", "HAState", "of", "the", "engine", "and", "dispatches", "events", "when", "the", "state", "changes", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L114-L139
26,632
google/seesaw
engine/ha.go
setStatus
func (h *haManager) setStatus(s seesaw.HAStatus) { h.setState(s.State) h.statusLock.Lock() h.status.Since = s.Since h.status.Sent = s.Sent h.status.Received = s.Received h.status.Transitions = s.Transitions h.statusLock.Unlock() }
go
func (h *haManager) setStatus(s seesaw.HAStatus) { h.setState(s.State) h.statusLock.Lock() h.status.Since = s.Since h.status.Sent = s.Sent h.status.Received = s.Received h.status.Transitions = s.Transitions h.statusLock.Unlock() }
[ "func", "(", "h", "*", "haManager", ")", "setStatus", "(", "s", "seesaw", ".", "HAStatus", ")", "{", "h", ".", "setState", "(", "s", ".", "State", ")", "\n\n", "h", ".", "statusLock", ".", "Lock", "(", ")", "\n", "h", ".", "status", ".", "Since",...
// setStatus updates the engine HAStatus.
[ "setStatus", "updates", "the", "engine", "HAStatus", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L142-L151
26,633
google/seesaw
engine/ha.go
timer
func (h *haManager) timer() <-chan time.Time { if s := h.state(); s == seesaw.HADisabled || s == seesaw.HAUnknown { return make(chan time.Time) } // TODO(angusc): Make this clock-jump safe. h.statusLock.RLock() deadline := h.status.LastUpdate.Add(h.timeout) h.statusLock.RUnlock() return time.After(deadline.Sub...
go
func (h *haManager) timer() <-chan time.Time { if s := h.state(); s == seesaw.HADisabled || s == seesaw.HAUnknown { return make(chan time.Time) } // TODO(angusc): Make this clock-jump safe. h.statusLock.RLock() deadline := h.status.LastUpdate.Add(h.timeout) h.statusLock.RUnlock() return time.After(deadline.Sub...
[ "func", "(", "h", "*", "haManager", ")", "timer", "(", ")", "<-", "chan", "time", ".", "Time", "{", "if", "s", ":=", "h", ".", "state", "(", ")", ";", "s", "==", "seesaw", ".", "HADisabled", "||", "s", "==", "seesaw", ".", "HAUnknown", "{", "re...
// timer returns a channel that receives a Time object when the current HA state // expires.
[ "timer", "returns", "a", "channel", "that", "receives", "a", "Time", "object", "when", "the", "current", "HA", "state", "expires", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/engine/ha.go#L155-L164
26,634
google/seesaw
cli/core.go
Execute
func (cli *SeesawCLI) Execute(cmdline string) error { cmd, subcmds, _, args := FindCommand(cmdline) if cmd != nil { return cmd.function(cli, args) } if subcmds != nil { return errors.New("Incomplete command.") } return errors.New("Unknown command.") }
go
func (cli *SeesawCLI) Execute(cmdline string) error { cmd, subcmds, _, args := FindCommand(cmdline) if cmd != nil { return cmd.function(cli, args) } if subcmds != nil { return errors.New("Incomplete command.") } return errors.New("Unknown command.") }
[ "func", "(", "cli", "*", "SeesawCLI", ")", "Execute", "(", "cmdline", "string", ")", "error", "{", "cmd", ",", "subcmds", ",", "_", ",", "args", ":=", "FindCommand", "(", "cmdline", ")", "\n", "if", "cmd", "!=", "nil", "{", "return", "cmd", ".", "f...
// Execute executes the given command line.
[ "Execute", "executes", "the", "given", "command", "line", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/cli/core.go#L40-L49
26,635
google/seesaw
cli/core.go
FindCommand
func FindCommand(cmdline string) (*Command, *[]Command, []*Command, []string) { var chain []*Command var matches []Command var next *Command cmds := &commands // Tokenise string. cmdstr := strings.Fields(cmdline) if len(cmdstr) == 0 { return nil, cmds, chain, nil } for idx, subcmd := range cmdstr { match...
go
func FindCommand(cmdline string) (*Command, *[]Command, []*Command, []string) { var chain []*Command var matches []Command var next *Command cmds := &commands // Tokenise string. cmdstr := strings.Fields(cmdline) if len(cmdstr) == 0 { return nil, cmds, chain, nil } for idx, subcmd := range cmdstr { match...
[ "func", "FindCommand", "(", "cmdline", "string", ")", "(", "*", "Command", ",", "*", "[", "]", "Command", ",", "[", "]", "*", "Command", ",", "[", "]", "string", ")", "{", "var", "chain", "[", "]", "*", "Command", "\n", "var", "matches", "[", "]"...
// FindCommand tokenises a command line and attempts to locate the // corresponding Command. If a matching command is found it is returned, // along with the remaining arguments. If the command has sub-commands then // the list of sub-commands is returned instead. A chain of matched commands // is also returned, along ...
[ "FindCommand", "tokenises", "a", "command", "line", "and", "attempts", "to", "locate", "the", "corresponding", "Command", ".", "If", "a", "matching", "command", "is", "found", "it", "is", "returned", "along", "with", "the", "remaining", "arguments", ".", "If",...
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/cli/core.go#L113-L155
26,636
google/seesaw
quagga/bgp.go
String
func (s BGPState) String() string { if name, ok := stateNames[s]; ok { return name } return "Unknown" }
go
func (s BGPState) String() string { if name, ok := stateNames[s]; ok { return name } return "Unknown" }
[ "func", "(", "s", "BGPState", ")", "String", "(", ")", "string", "{", "if", "name", ",", "ok", ":=", "stateNames", "[", "s", "]", ";", "ok", "{", "return", "name", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// String returns a string representation of the given BGP state.
[ "String", "returns", "a", "string", "representation", "of", "the", "given", "BGP", "state", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L60-L65
26,637
google/seesaw
quagga/bgp.go
BGPStateByName
func BGPStateByName(name string) BGPState { name = strings.ToLower(name) for s := range stateNames { if strings.ToLower(stateNames[s]) == name { return s } } return BGPStateUnknown }
go
func BGPStateByName(name string) BGPState { name = strings.ToLower(name) for s := range stateNames { if strings.ToLower(stateNames[s]) == name { return s } } return BGPStateUnknown }
[ "func", "BGPStateByName", "(", "name", "string", ")", "BGPState", "{", "name", "=", "strings", ".", "ToLower", "(", "name", ")", "\n", "for", "s", ":=", "range", "stateNames", "{", "if", "strings", ".", "ToLower", "(", "stateNames", "[", "s", "]", ")",...
// BGPStateByName returns the BGP state that corresponds to the given name.
[ "BGPStateByName", "returns", "the", "BGP", "state", "that", "corresponds", "to", "the", "given", "name", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L68-L76
26,638
google/seesaw
quagga/bgp.go
NewBGP
func NewBGP(socket string, asn uint32) *BGP { if socket == "" { socket = BGPSocketPath } return &BGP{ vty: NewVTY(socket), asn: asn, } }
go
func NewBGP(socket string, asn uint32) *BGP { if socket == "" { socket = BGPSocketPath } return &BGP{ vty: NewVTY(socket), asn: asn, } }
[ "func", "NewBGP", "(", "socket", "string", ",", "asn", "uint32", ")", "*", "BGP", "{", "if", "socket", "==", "\"", "\"", "{", "socket", "=", "BGPSocketPath", "\n", "}", "\n", "return", "&", "BGP", "{", "vty", ":", "NewVTY", "(", "socket", ")", ",",...
// NewBGP returns an initialised BGP structure.
[ "NewBGP", "returns", "an", "initialised", "BGP", "structure", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L156-L164
26,639
google/seesaw
quagga/bgp.go
Enable
func (b *BGP) Enable() error { _, err := b.vty.Command("enable") return err }
go
func (b *BGP) Enable() error { _, err := b.vty.Command("enable") return err }
[ "func", "(", "b", "*", "BGP", ")", "Enable", "(", ")", "error", "{", "_", ",", "err", ":=", "b", ".", "vty", ".", "Command", "(", "\"", "\"", ")", "\n", "return", "err", "\n", "}" ]
// Enable issues an "enable" command to the BGP daemon.
[ "Enable", "issues", "an", "enable", "command", "to", "the", "BGP", "daemon", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L177-L180
26,640
google/seesaw
quagga/bgp.go
Configuration
func (b *BGP) Configuration() ([]string, error) { cfg, err := b.vty.Command("write terminal") if err != nil { return nil, err } return strings.Split(cfg, "\n"), nil }
go
func (b *BGP) Configuration() ([]string, error) { cfg, err := b.vty.Command("write terminal") if err != nil { return nil, err } return strings.Split(cfg, "\n"), nil }
[ "func", "(", "b", "*", "BGP", ")", "Configuration", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "cfg", ",", "err", ":=", "b", ".", "vty", ".", "Command", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil...
// Configuration returns the current running configuration from the BGP daemon, // as a slice of strings.
[ "Configuration", "returns", "the", "current", "running", "configuration", "from", "the", "BGP", "daemon", "as", "a", "slice", "of", "strings", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L184-L190
26,641
google/seesaw
quagga/bgp.go
Neighbors
func (b *BGP) Neighbors() ([]*Neighbor, error) { ni, err := b.vty.Command("show ip bgp neighbors") if err != nil { return nil, err } // TODO(jsing): Include details for advertised/received routes. return parseNeighbors(ni), nil }
go
func (b *BGP) Neighbors() ([]*Neighbor, error) { ni, err := b.vty.Command("show ip bgp neighbors") if err != nil { return nil, err } // TODO(jsing): Include details for advertised/received routes. return parseNeighbors(ni), nil }
[ "func", "(", "b", "*", "BGP", ")", "Neighbors", "(", ")", "(", "[", "]", "*", "Neighbor", ",", "error", ")", "{", "ni", ",", "err", ":=", "b", ".", "vty", ".", "Command", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Neighbors returns a list of BGP neighbors that we are currently peering with.
[ "Neighbors", "returns", "a", "list", "of", "BGP", "neighbors", "that", "we", "are", "currently", "peering", "with", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L193-L200
26,642
google/seesaw
quagga/bgp.go
network
func (b *BGP) network(n *net.IPNet, advertise bool) error { var prefix string if !advertise { prefix = "no " } family := "ipv4 unicast" if n.IP.To4() == nil { family = "ipv6" } prefixLen, _ := n.Mask.Size() cmds := []string{ "configure terminal", fmt.Sprintf("router bgp %d", b.asn), fmt.Sprintf("addre...
go
func (b *BGP) network(n *net.IPNet, advertise bool) error { var prefix string if !advertise { prefix = "no " } family := "ipv4 unicast" if n.IP.To4() == nil { family = "ipv6" } prefixLen, _ := n.Mask.Size() cmds := []string{ "configure terminal", fmt.Sprintf("router bgp %d", b.asn), fmt.Sprintf("addre...
[ "func", "(", "b", "*", "BGP", ")", "network", "(", "n", "*", "net", ".", "IPNet", ",", "advertise", "bool", ")", "error", "{", "var", "prefix", "string", "\n", "if", "!", "advertise", "{", "prefix", "=", "\"", "\"", "\n", "}", "\n", "family", ":=...
// network adds or removes a network statement from the BGP configuration.
[ "network", "adds", "or", "removes", "a", "network", "statement", "from", "the", "BGP", "configuration", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L203-L223
26,643
google/seesaw
quagga/bgp.go
Advertise
func (b *BGP) Advertise(n *net.IPNet) error { return b.network(n, true) }
go
func (b *BGP) Advertise(n *net.IPNet) error { return b.network(n, true) }
[ "func", "(", "b", "*", "BGP", ")", "Advertise", "(", "n", "*", "net", ".", "IPNet", ")", "error", "{", "return", "b", ".", "network", "(", "n", ",", "true", ")", "\n", "}" ]
// Advertise requests the BGP daemon to advertise the specified network.
[ "Advertise", "requests", "the", "BGP", "daemon", "to", "advertise", "the", "specified", "network", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L226-L228
26,644
google/seesaw
quagga/bgp.go
Withdraw
func (b *BGP) Withdraw(n *net.IPNet) error { return b.network(n, false) }
go
func (b *BGP) Withdraw(n *net.IPNet) error { return b.network(n, false) }
[ "func", "(", "b", "*", "BGP", ")", "Withdraw", "(", "n", "*", "net", ".", "IPNet", ")", "error", "{", "return", "b", ".", "network", "(", "n", ",", "false", ")", "\n", "}" ]
// Withdraw requests the BGP daemon to withdraw advertisements for the // specified network.
[ "Withdraw", "requests", "the", "BGP", "daemon", "to", "withdraw", "advertisements", "for", "the", "specified", "network", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L232-L234
26,645
google/seesaw
quagga/bgp.go
parseNeighbors
func parseNeighbors(sn string) []*Neighbor { neighbors := make([]*Neighbor, 0) var neighbor *Neighbor var msgStats bool for _, s := range strings.Split(sn, "\n") { if nm := neighborRE.FindStringSubmatch(s); nm != nil { asn, _ := strconv.ParseUint(nm[2], 10, 32) neighbor = &Neighbor{ IP: net.ParseIP(nm[...
go
func parseNeighbors(sn string) []*Neighbor { neighbors := make([]*Neighbor, 0) var neighbor *Neighbor var msgStats bool for _, s := range strings.Split(sn, "\n") { if nm := neighborRE.FindStringSubmatch(s); nm != nil { asn, _ := strconv.ParseUint(nm[2], 10, 32) neighbor = &Neighbor{ IP: net.ParseIP(nm[...
[ "func", "parseNeighbors", "(", "sn", "string", ")", "[", "]", "*", "Neighbor", "{", "neighbors", ":=", "make", "(", "[", "]", "*", "Neighbor", ",", "0", ")", "\n", "var", "neighbor", "*", "Neighbor", "\n", "var", "msgStats", "bool", "\n", "for", "_",...
// parseNeighbors parses the "show ip bgp neighbors" output from the Quagga // BGP daemon and returns a slice of Neighbor structs.
[ "parseNeighbors", "parses", "the", "show", "ip", "bgp", "neighbors", "output", "from", "the", "Quagga", "BGP", "daemon", "and", "returns", "a", "slice", "of", "Neighbor", "structs", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/quagga/bgp.go#L246-L304
26,646
google/seesaw
healthcheck/udp.go
NewUDPChecker
func NewUDPChecker(ip net.IP, port int) *UDPChecker { return &UDPChecker{ Target: Target{ IP: ip, Port: port, Proto: seesaw.IPProtoUDP, }, } }
go
func NewUDPChecker(ip net.IP, port int) *UDPChecker { return &UDPChecker{ Target: Target{ IP: ip, Port: port, Proto: seesaw.IPProtoUDP, }, } }
[ "func", "NewUDPChecker", "(", "ip", "net", ".", "IP", ",", "port", "int", ")", "*", "UDPChecker", "{", "return", "&", "UDPChecker", "{", "Target", ":", "Target", "{", "IP", ":", "ip", ",", "Port", ":", "port", ",", "Proto", ":", "seesaw", ".", "IPP...
// NewUDPChecker returns an initialised UDPChecker.
[ "NewUDPChecker", "returns", "an", "initialised", "UDPChecker", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/udp.go#L41-L49
26,647
google/seesaw
healthcheck/udp.go
Check
func (hc *UDPChecker) Check(timeout time.Duration) *Result { msg := fmt.Sprintf("UDP check to %s", hc.addr()) start := time.Now() if timeout == time.Duration(0) { timeout = defaultUDPTimeout } deadline := start.Add(timeout) conn, err := dialUDP(hc.network(), hc.addr(), timeout, hc.Mark) if err != nil { msg ...
go
func (hc *UDPChecker) Check(timeout time.Duration) *Result { msg := fmt.Sprintf("UDP check to %s", hc.addr()) start := time.Now() if timeout == time.Duration(0) { timeout = defaultUDPTimeout } deadline := start.Add(timeout) conn, err := dialUDP(hc.network(), hc.addr(), timeout, hc.Mark) if err != nil { msg ...
[ "func", "(", "hc", "*", "UDPChecker", ")", "Check", "(", "timeout", "time", ".", "Duration", ")", "*", "Result", "{", "msg", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "hc", ".", "addr", "(", ")", ")", "\n", "start", ":=", "time", ".", ...
// Check executes a UDP healthcheck.
[ "Check", "executes", "a", "UDP", "healthcheck", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/healthcheck/udp.go#L57-L96
26,648
google/seesaw
binaries/seesaw_engine/main.go
cfgOpt
func cfgOpt(cfg *conf.ConfigFile, section, option string) string { if !cfg.HasOption(section, option) { return "" } s, err := cfg.GetString(section, option) if err != nil { log.Exitf("Failed to get %s for %s: %v", option, section, err) } return s }
go
func cfgOpt(cfg *conf.ConfigFile, section, option string) string { if !cfg.HasOption(section, option) { return "" } s, err := cfg.GetString(section, option) if err != nil { log.Exitf("Failed to get %s for %s: %v", option, section, err) } return s }
[ "func", "cfgOpt", "(", "cfg", "*", "conf", ".", "ConfigFile", ",", "section", ",", "option", "string", ")", "string", "{", "if", "!", "cfg", ".", "HasOption", "(", "section", ",", "option", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "s", ",",...
// cfgOpt returns the configuration option from the specified section. If the // option does not exist an empty string is returned.
[ "cfgOpt", "returns", "the", "configuration", "option", "from", "the", "specified", "section", ".", "If", "the", "option", "does", "not", "exist", "an", "empty", "string", "is", "returned", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_engine/main.go#L49-L58
26,649
google/seesaw
binaries/seesaw_engine/main.go
cfgIP
func cfgIP(cfg *conf.ConfigFile, section, option string) (net.IP, error) { ipStr := cfgOpt(cfg, section, option) if ipStr == "" { return nil, nil } ip := net.ParseIP(ipStr) if ip == nil { return nil, fmt.Errorf("%s: %q is not a valid IP address", option, ipStr) } return ip, nil }
go
func cfgIP(cfg *conf.ConfigFile, section, option string) (net.IP, error) { ipStr := cfgOpt(cfg, section, option) if ipStr == "" { return nil, nil } ip := net.ParseIP(ipStr) if ip == nil { return nil, fmt.Errorf("%s: %q is not a valid IP address", option, ipStr) } return ip, nil }
[ "func", "cfgIP", "(", "cfg", "*", "conf", ".", "ConfigFile", ",", "section", ",", "option", "string", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "ipStr", ":=", "cfgOpt", "(", "cfg", ",", "section", ",", "option", ")", "\n", "if", "ipStr", ...
// cfgIP returns configuration option from the specified section, as an IP // address. If the option does not exist or is blank, a nil IP is returned.
[ "cfgIP", "returns", "configuration", "option", "from", "the", "specified", "section", "as", "an", "IP", "address", ".", "If", "the", "option", "does", "not", "exist", "or", "is", "blank", "a", "nil", "IP", "is", "returned", "." ]
34716af0775ecb1fad239a726390d63d6b0742dd
https://github.com/google/seesaw/blob/34716af0775ecb1fad239a726390d63d6b0742dd/binaries/seesaw_engine/main.go#L62-L72
26,650
nats-io/nats-streaming-server
server/raft_log.go
Close
func (r *raftLog) Close() error { r.Lock() if r.closed { r.Unlock() return nil } r.closed = true err := r.conn.Close() r.Unlock() return err }
go
func (r *raftLog) Close() error { r.Lock() if r.closed { r.Unlock() return nil } r.closed = true err := r.conn.Close() r.Unlock() return err }
[ "func", "(", "r", "*", "raftLog", ")", "Close", "(", ")", "error", "{", "r", ".", "Lock", "(", ")", "\n", "if", "r", ".", "closed", "{", "r", ".", "Unlock", "(", ")", "\n", "return", "nil", "\n", "}", "\n", "r", ".", "closed", "=", "true", ...
// Close implements the LogStore interface
[ "Close", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L159-L169
26,651
nats-io/nats-streaming-server
server/raft_log.go
FirstIndex
func (r *raftLog) FirstIndex() (uint64, error) { r.RLock() idx, err := r.getIndex(true) r.RUnlock() return idx, err }
go
func (r *raftLog) FirstIndex() (uint64, error) { r.RLock() idx, err := r.getIndex(true) r.RUnlock() return idx, err }
[ "func", "(", "r", "*", "raftLog", ")", "FirstIndex", "(", ")", "(", "uint64", ",", "error", ")", "{", "r", ".", "RLock", "(", ")", "\n", "idx", ",", "err", ":=", "r", ".", "getIndex", "(", "true", ")", "\n", "r", ".", "RUnlock", "(", ")", "\n...
// FirstIndex implements the LogStore interface
[ "FirstIndex", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L172-L177
26,652
nats-io/nats-streaming-server
server/raft_log.go
LastIndex
func (r *raftLog) LastIndex() (uint64, error) { r.RLock() idx, err := r.getIndex(false) r.RUnlock() return idx, err }
go
func (r *raftLog) LastIndex() (uint64, error) { r.RLock() idx, err := r.getIndex(false) r.RUnlock() return idx, err }
[ "func", "(", "r", "*", "raftLog", ")", "LastIndex", "(", ")", "(", "uint64", ",", "error", ")", "{", "r", ".", "RLock", "(", ")", "\n", "idx", ",", "err", ":=", "r", ".", "getIndex", "(", "false", ")", "\n", "r", ".", "RUnlock", "(", ")", "\n...
// LastIndex implements the LogStore interface
[ "LastIndex", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L180-L185
26,653
nats-io/nats-streaming-server
server/raft_log.go
GetLog
func (r *raftLog) GetLog(idx uint64, log *raft.Log) error { r.RLock() tx, err := r.conn.Begin(false) if err != nil { r.RUnlock() return err } var key [8]byte binary.BigEndian.PutUint64(key[:], idx) bucket := tx.Bucket(logsBucket) val := bucket.Get(key[:]) if val == nil { err = raft.ErrLogNotFound } else...
go
func (r *raftLog) GetLog(idx uint64, log *raft.Log) error { r.RLock() tx, err := r.conn.Begin(false) if err != nil { r.RUnlock() return err } var key [8]byte binary.BigEndian.PutUint64(key[:], idx) bucket := tx.Bucket(logsBucket) val := bucket.Get(key[:]) if val == nil { err = raft.ErrLogNotFound } else...
[ "func", "(", "r", "*", "raftLog", ")", "GetLog", "(", "idx", "uint64", ",", "log", "*", "raft", ".", "Log", ")", "error", "{", "r", ".", "RLock", "(", ")", "\n", "tx", ",", "err", ":=", "r", ".", "conn", ".", "Begin", "(", "false", ")", "\n",...
// GetLog implements the LogStore interface
[ "GetLog", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L212-L231
26,654
nats-io/nats-streaming-server
server/raft_log.go
StoreLog
func (r *raftLog) StoreLog(log *raft.Log) error { return r.StoreLogs([]*raft.Log{log}) }
go
func (r *raftLog) StoreLog(log *raft.Log) error { return r.StoreLogs([]*raft.Log{log}) }
[ "func", "(", "r", "*", "raftLog", ")", "StoreLog", "(", "log", "*", "raft", ".", "Log", ")", "error", "{", "return", "r", ".", "StoreLogs", "(", "[", "]", "*", "raft", ".", "Log", "{", "log", "}", ")", "\n", "}" ]
// StoreLog implements the LogStore interface
[ "StoreLog", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L234-L236
26,655
nats-io/nats-streaming-server
server/raft_log.go
StoreLogs
func (r *raftLog) StoreLogs(logs []*raft.Log) error { r.Lock() tx, err := r.conn.Begin(true) if err != nil { r.Unlock() return err } bucket := tx.Bucket(logsBucket) for _, log := range logs { var ( key [8]byte val []byte ) binary.BigEndian.PutUint64(key[:], log.Index) val, err = r.encodeRaftLog(...
go
func (r *raftLog) StoreLogs(logs []*raft.Log) error { r.Lock() tx, err := r.conn.Begin(true) if err != nil { r.Unlock() return err } bucket := tx.Bucket(logsBucket) for _, log := range logs { var ( key [8]byte val []byte ) binary.BigEndian.PutUint64(key[:], log.Index) val, err = r.encodeRaftLog(...
[ "func", "(", "r", "*", "raftLog", ")", "StoreLogs", "(", "logs", "[", "]", "*", "raft", ".", "Log", ")", "error", "{", "r", ".", "Lock", "(", ")", "\n", "tx", ",", "err", ":=", "r", ".", "conn", ".", "Begin", "(", "true", ")", "\n", "if", "...
// StoreLogs implements the LogStore interface
[ "StoreLogs", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L239-L269
26,656
nats-io/nats-streaming-server
server/raft_log.go
DeleteRange
func (r *raftLog) DeleteRange(min, max uint64) (retErr error) { r.Lock() defer r.Unlock() start := time.Now() r.log.Noticef("Deleting raft logs from %v to %v", min, max) err := r.deleteRange(min, max) dur := time.Since(start) durTxt := fmt.Sprintf("Deletion took %v", dur) if dur > 2*time.Second { r.log.Error...
go
func (r *raftLog) DeleteRange(min, max uint64) (retErr error) { r.Lock() defer r.Unlock() start := time.Now() r.log.Noticef("Deleting raft logs from %v to %v", min, max) err := r.deleteRange(min, max) dur := time.Since(start) durTxt := fmt.Sprintf("Deletion took %v", dur) if dur > 2*time.Second { r.log.Error...
[ "func", "(", "r", "*", "raftLog", ")", "DeleteRange", "(", "min", ",", "max", "uint64", ")", "(", "retErr", "error", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n\n", "start", ":=", "time", ".", "Now", "...
// DeleteRange implements the LogStore interface
[ "DeleteRange", "implements", "the", "LogStore", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L272-L287
26,657
nats-io/nats-streaming-server
server/raft_log.go
Set
func (r *raftLog) Set(k, v []byte) error { r.Lock() tx, err := r.conn.Begin(true) if err != nil { r.Unlock() return err } bucket := tx.Bucket(confBucket) err = bucket.Put(k, v) if err != nil { tx.Rollback() } else { err = tx.Commit() } r.Unlock() return err }
go
func (r *raftLog) Set(k, v []byte) error { r.Lock() tx, err := r.conn.Begin(true) if err != nil { r.Unlock() return err } bucket := tx.Bucket(confBucket) err = bucket.Put(k, v) if err != nil { tx.Rollback() } else { err = tx.Commit() } r.Unlock() return err }
[ "func", "(", "r", "*", "raftLog", ")", "Set", "(", "k", ",", "v", "[", "]", "byte", ")", "error", "{", "r", ".", "Lock", "(", ")", "\n", "tx", ",", "err", ":=", "r", ".", "conn", ".", "Begin", "(", "true", ")", "\n", "if", "err", "!=", "n...
// Set implements the Stable interface
[ "Set", "implements", "the", "Stable", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L314-L330
26,658
nats-io/nats-streaming-server
server/raft_log.go
Get
func (r *raftLog) Get(k []byte) ([]byte, error) { r.RLock() tx, err := r.conn.Begin(false) if err != nil { r.RUnlock() return nil, err } var v []byte bucket := tx.Bucket(confBucket) val := bucket.Get(k) if val == nil { err = errKeyNotFound } else { // Make a copy v = append([]byte(nil), val...) } t...
go
func (r *raftLog) Get(k []byte) ([]byte, error) { r.RLock() tx, err := r.conn.Begin(false) if err != nil { r.RUnlock() return nil, err } var v []byte bucket := tx.Bucket(confBucket) val := bucket.Get(k) if val == nil { err = errKeyNotFound } else { // Make a copy v = append([]byte(nil), val...) } t...
[ "func", "(", "r", "*", "raftLog", ")", "Get", "(", "k", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "r", ".", "RLock", "(", ")", "\n", "tx", ",", "err", ":=", "r", ".", "conn", ".", "Begin", "(", "false", ")", "\...
// Get implements the Stable interface
[ "Get", "implements", "the", "Stable", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L333-L352
26,659
nats-io/nats-streaming-server
server/raft_log.go
SetUint64
func (r *raftLog) SetUint64(k []byte, v uint64) error { var vbytes [8]byte binary.BigEndian.PutUint64(vbytes[:], v) err := r.Set(k, vbytes[:]) return err }
go
func (r *raftLog) SetUint64(k []byte, v uint64) error { var vbytes [8]byte binary.BigEndian.PutUint64(vbytes[:], v) err := r.Set(k, vbytes[:]) return err }
[ "func", "(", "r", "*", "raftLog", ")", "SetUint64", "(", "k", "[", "]", "byte", ",", "v", "uint64", ")", "error", "{", "var", "vbytes", "[", "8", "]", "byte", "\n", "binary", ".", "BigEndian", ".", "PutUint64", "(", "vbytes", "[", ":", "]", ",", ...
// SetUint64 implements the Stable interface
[ "SetUint64", "implements", "the", "Stable", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L355-L360
26,660
nats-io/nats-streaming-server
server/raft_log.go
GetUint64
func (r *raftLog) GetUint64(k []byte) (uint64, error) { var v uint64 vbytes, err := r.Get(k) if err == nil { v = binary.BigEndian.Uint64(vbytes) } return v, err }
go
func (r *raftLog) GetUint64(k []byte) (uint64, error) { var v uint64 vbytes, err := r.Get(k) if err == nil { v = binary.BigEndian.Uint64(vbytes) } return v, err }
[ "func", "(", "r", "*", "raftLog", ")", "GetUint64", "(", "k", "[", "]", "byte", ")", "(", "uint64", ",", "error", ")", "{", "var", "v", "uint64", "\n", "vbytes", ",", "err", ":=", "r", ".", "Get", "(", "k", ")", "\n", "if", "err", "==", "nil"...
// GetUint64 implements the Stable interface
[ "GetUint64", "implements", "the", "Stable", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/raft_log.go#L363-L370
26,661
nats-io/nats-streaming-server
server/snapshot.go
Restore
func (r *raftFSM) Restore(snapshot io.ReadCloser) (retErr error) { s := r.server defer snapshot.Close() r.Lock() defer r.Unlock() // This function may be invoked directly from raft.NewRaft() when // the node is initialized and if there were exisiting local snapshots, // or later, when catching up with a leader...
go
func (r *raftFSM) Restore(snapshot io.ReadCloser) (retErr error) { s := r.server defer snapshot.Close() r.Lock() defer r.Unlock() // This function may be invoked directly from raft.NewRaft() when // the node is initialized and if there were exisiting local snapshots, // or later, when catching up with a leader...
[ "func", "(", "r", "*", "raftFSM", ")", "Restore", "(", "snapshot", "io", ".", "ReadCloser", ")", "(", "retErr", "error", ")", "{", "s", ":=", "r", ".", "server", "\n", "defer", "snapshot", ".", "Close", "(", ")", "\n\n", "r", ".", "Lock", "(", ")...
// Restore is used to restore an FSM from a snapshot. It is not called // concurrently with any other command. The FSM must discard all previous // state.
[ "Restore", "is", "used", "to", "restore", "an", "FSM", "from", "a", "snapshot", ".", "It", "is", "not", "called", "concurrently", "with", "any", "other", "command", ".", "The", "FSM", "must", "discard", "all", "previous", "state", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/snapshot.go#L225-L305
26,662
nats-io/nats-streaming-server
stores/raftstore.go
NewRaftStore
func NewRaftStore(log logger.Logger, s Store, limits *StoreLimits) *RaftStore { return &RaftStore{Store: s, log: log} }
go
func NewRaftStore(log logger.Logger, s Store, limits *StoreLimits) *RaftStore { return &RaftStore{Store: s, log: log} }
[ "func", "NewRaftStore", "(", "log", "logger", ".", "Logger", ",", "s", "Store", ",", "limits", "*", "StoreLimits", ")", "*", "RaftStore", "{", "return", "&", "RaftStore", "{", "Store", ":", "s", ",", "log", ":", "log", "}", "\n", "}" ]
// NewRaftStore returns an instarce of a RaftStore
[ "NewRaftStore", "returns", "an", "instarce", "of", "a", "RaftStore" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/raftstore.go#L40-L42
26,663
nats-io/nats-streaming-server
stores/common.go
setLimits
func (gs *genericStore) setLimits(limits *StoreLimits) error { // Make a copy. gs.limits = limits.Clone() // Build will validate and apply inheritance if no error. if err := gs.limits.Build(); err != nil { return err } // We don't need the PerChannel map and the sublist. So replace // the map with the sublist ...
go
func (gs *genericStore) setLimits(limits *StoreLimits) error { // Make a copy. gs.limits = limits.Clone() // Build will validate and apply inheritance if no error. if err := gs.limits.Build(); err != nil { return err } // We don't need the PerChannel map and the sublist. So replace // the map with the sublist ...
[ "func", "(", "gs", "*", "genericStore", ")", "setLimits", "(", "limits", "*", "StoreLimits", ")", "error", "{", "// Make a copy.", "gs", ".", "limits", "=", "limits", ".", "Clone", "(", ")", "\n", "// Build will validate and apply inheritance if no error.", "if", ...
// setLimits makes a copy of the given StoreLimits, // validates the limits and if ok, applies the inheritance.
[ "setLimits", "makes", "a", "copy", "of", "the", "given", "StoreLimits", "validates", "the", "limits", "and", "if", "ok", "applies", "the", "inheritance", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L115-L133
26,664
nats-io/nats-streaming-server
stores/common.go
getChannelLimits
func (gs *genericStore) getChannelLimits(channel string) *ChannelLimits { r := gs.sublist.Match(channel) if len(r) == 0 { // If there is no match, that means we need to use the global limits. return &gs.limits.ChannelLimits } // If there is a match, use the limits from the last element because // we know that ...
go
func (gs *genericStore) getChannelLimits(channel string) *ChannelLimits { r := gs.sublist.Match(channel) if len(r) == 0 { // If there is no match, that means we need to use the global limits. return &gs.limits.ChannelLimits } // If there is a match, use the limits from the last element because // we know that ...
[ "func", "(", "gs", "*", "genericStore", ")", "getChannelLimits", "(", "channel", "string", ")", "*", "ChannelLimits", "{", "r", ":=", "gs", ".", "sublist", ".", "Match", "(", "channel", ")", "\n", "if", "len", "(", "r", ")", "==", "0", "{", "// If th...
// Returns the appropriate limits for this channel based on inheritance. // The channel is assumed to be a literal, and the store lock held on entry.
[ "Returns", "the", "appropriate", "limits", "for", "this", "channel", "based", "on", "inheritance", ".", "The", "channel", "is", "assumed", "to", "be", "a", "literal", "and", "the", "store", "lock", "held", "on", "entry", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L137-L148
26,665
nats-io/nats-streaming-server
stores/common.go
GetChannelLimits
func (gs *genericStore) GetChannelLimits(channel string) *ChannelLimits { gs.RLock() defer gs.RUnlock() c := gs.channels[channel] if c == nil { return nil } // Return a copy cl := *gs.getChannelLimits(channel) return &cl }
go
func (gs *genericStore) GetChannelLimits(channel string) *ChannelLimits { gs.RLock() defer gs.RUnlock() c := gs.channels[channel] if c == nil { return nil } // Return a copy cl := *gs.getChannelLimits(channel) return &cl }
[ "func", "(", "gs", "*", "genericStore", ")", "GetChannelLimits", "(", "channel", "string", ")", "*", "ChannelLimits", "{", "gs", ".", "RLock", "(", ")", "\n", "defer", "gs", ".", "RUnlock", "(", ")", "\n", "c", ":=", "gs", ".", "channels", "[", "chan...
// GetChannelLimits implements the Store interface
[ "GetChannelLimits", "implements", "the", "Store", "interface" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L151-L161
26,666
nats-io/nats-streaming-server
stores/common.go
SetLimits
func (gs *genericStore) SetLimits(limits *StoreLimits) error { gs.Lock() err := gs.setLimits(limits) gs.Unlock() return err }
go
func (gs *genericStore) SetLimits(limits *StoreLimits) error { gs.Lock() err := gs.setLimits(limits) gs.Unlock() return err }
[ "func", "(", "gs", "*", "genericStore", ")", "SetLimits", "(", "limits", "*", "StoreLimits", ")", "error", "{", "gs", ".", "Lock", "(", ")", "\n", "err", ":=", "gs", ".", "setLimits", "(", "limits", ")", "\n", "gs", ".", "Unlock", "(", ")", "\n", ...
// SetLimits sets limits for this store
[ "SetLimits", "sets", "limits", "for", "this", "store" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L164-L169
26,667
nats-io/nats-streaming-server
stores/common.go
canAddChannel
func (gs *genericStore) canAddChannel(name string) error { if gs.channels[name] != nil { return ErrAlreadyExists } if gs.limits.MaxChannels > 0 && len(gs.channels) >= gs.limits.MaxChannels { return ErrTooManyChannels } return nil }
go
func (gs *genericStore) canAddChannel(name string) error { if gs.channels[name] != nil { return ErrAlreadyExists } if gs.limits.MaxChannels > 0 && len(gs.channels) >= gs.limits.MaxChannels { return ErrTooManyChannels } return nil }
[ "func", "(", "gs", "*", "genericStore", ")", "canAddChannel", "(", "name", "string", ")", "error", "{", "if", "gs", ".", "channels", "[", "name", "]", "!=", "nil", "{", "return", "ErrAlreadyExists", "\n", "}", "\n", "if", "gs", ".", "limits", ".", "M...
// canAddChannel returns true if the current number of channels is below the limit. // If a channel named `channelName` alreadt exists, an error is returned. // Store lock is assumed to be locked.
[ "canAddChannel", "returns", "true", "if", "the", "current", "number", "of", "channels", "is", "below", "the", "limit", ".", "If", "a", "channel", "named", "channelName", "alreadt", "exists", "an", "error", "is", "returned", ".", "Store", "lock", "is", "assum...
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L203-L211
26,668
nats-io/nats-streaming-server
stores/common.go
Close
func (gs *genericStore) Close() error { gs.Lock() defer gs.Unlock() if gs.closed { return nil } gs.closed = true return gs.close() }
go
func (gs *genericStore) Close() error { gs.Lock() defer gs.Unlock() if gs.closed { return nil } gs.closed = true return gs.close() }
[ "func", "(", "gs", "*", "genericStore", ")", "Close", "(", ")", "error", "{", "gs", ".", "Lock", "(", ")", "\n", "defer", "gs", ".", "Unlock", "(", ")", "\n", "if", "gs", ".", "closed", "{", "return", "nil", "\n", "}", "\n", "gs", ".", "closed"...
// Close closes all stores
[ "Close", "closes", "all", "stores" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L224-L232
26,669
nats-io/nats-streaming-server
stores/common.go
close
func (gs *genericStore) close() error { var err error var lerr error for _, cs := range gs.channels { lerr = cs.Subs.Close() if lerr != nil && err == nil { err = lerr } lerr = cs.Msgs.Close() if lerr != nil && err == nil { err = lerr } } return err }
go
func (gs *genericStore) close() error { var err error var lerr error for _, cs := range gs.channels { lerr = cs.Subs.Close() if lerr != nil && err == nil { err = lerr } lerr = cs.Msgs.Close() if lerr != nil && err == nil { err = lerr } } return err }
[ "func", "(", "gs", "*", "genericStore", ")", "close", "(", ")", "error", "{", "var", "err", "error", "\n", "var", "lerr", "error", "\n\n", "for", "_", ",", "cs", ":=", "range", "gs", ".", "channels", "{", "lerr", "=", "cs", ".", "Subs", ".", "Clo...
// close closes all stores. Store lock is assumed held on entry
[ "close", "closes", "all", "stores", ".", "Store", "lock", "is", "assumed", "held", "on", "entry" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L235-L250
26,670
nats-io/nats-streaming-server
stores/common.go
State
func (gms *genericMsgStore) State() (numMessages int, byteSize uint64, err error) { gms.RLock() c, b := gms.totalCount, gms.totalBytes gms.RUnlock() return c, b, nil }
go
func (gms *genericMsgStore) State() (numMessages int, byteSize uint64, err error) { gms.RLock() c, b := gms.totalCount, gms.totalBytes gms.RUnlock() return c, b, nil }
[ "func", "(", "gms", "*", "genericMsgStore", ")", "State", "(", ")", "(", "numMessages", "int", ",", "byteSize", "uint64", ",", "err", "error", ")", "{", "gms", ".", "RLock", "(", ")", "\n", "c", ",", "b", ":=", "gms", ".", "totalCount", ",", "gms",...
// State returns some statistics related to this store
[ "State", "returns", "some", "statistics", "related", "to", "this", "store" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L264-L269
26,671
nats-io/nats-streaming-server
stores/common.go
FirstSequence
func (gms *genericMsgStore) FirstSequence() (uint64, error) { gms.RLock() first := gms.first gms.RUnlock() return first, nil }
go
func (gms *genericMsgStore) FirstSequence() (uint64, error) { gms.RLock() first := gms.first gms.RUnlock() return first, nil }
[ "func", "(", "gms", "*", "genericMsgStore", ")", "FirstSequence", "(", ")", "(", "uint64", ",", "error", ")", "{", "gms", ".", "RLock", "(", ")", "\n", "first", ":=", "gms", ".", "first", "\n", "gms", ".", "RUnlock", "(", ")", "\n", "return", "firs...
// FirstSequence returns sequence for first message stored.
[ "FirstSequence", "returns", "sequence", "for", "first", "message", "stored", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L278-L283
26,672
nats-io/nats-streaming-server
stores/common.go
LastSequence
func (gms *genericMsgStore) LastSequence() (uint64, error) { gms.RLock() last := gms.last gms.RUnlock() return last, nil }
go
func (gms *genericMsgStore) LastSequence() (uint64, error) { gms.RLock() last := gms.last gms.RUnlock() return last, nil }
[ "func", "(", "gms", "*", "genericMsgStore", ")", "LastSequence", "(", ")", "(", "uint64", ",", "error", ")", "{", "gms", ".", "RLock", "(", ")", "\n", "last", ":=", "gms", ".", "last", "\n", "gms", ".", "RUnlock", "(", ")", "\n", "return", "last", ...
// LastSequence returns sequence for last message stored.
[ "LastSequence", "returns", "sequence", "for", "last", "message", "stored", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L286-L291
26,673
nats-io/nats-streaming-server
stores/common.go
FirstAndLastSequence
func (gms *genericMsgStore) FirstAndLastSequence() (uint64, uint64, error) { gms.RLock() first, last := gms.first, gms.last gms.RUnlock() return first, last, nil }
go
func (gms *genericMsgStore) FirstAndLastSequence() (uint64, uint64, error) { gms.RLock() first, last := gms.first, gms.last gms.RUnlock() return first, last, nil }
[ "func", "(", "gms", "*", "genericMsgStore", ")", "FirstAndLastSequence", "(", ")", "(", "uint64", ",", "uint64", ",", "error", ")", "{", "gms", ".", "RLock", "(", ")", "\n", "first", ",", "last", ":=", "gms", ".", "first", ",", "gms", ".", "last", ...
// FirstAndLastSequence returns sequences for the first and last messages stored.
[ "FirstAndLastSequence", "returns", "sequences", "for", "the", "first", "and", "last", "messages", "stored", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L294-L299
26,674
nats-io/nats-streaming-server
stores/common.go
CreateSub
func (gss *genericSubStore) CreateSub(sub *spb.SubState) error { gss.Lock() err := gss.createSub(sub) gss.Unlock() return err }
go
func (gss *genericSubStore) CreateSub(sub *spb.SubState) error { gss.Lock() err := gss.createSub(sub) gss.Unlock() return err }
[ "func", "(", "gss", "*", "genericSubStore", ")", "CreateSub", "(", "sub", "*", "spb", ".", "SubState", ")", "error", "{", "gss", ".", "Lock", "(", ")", "\n", "err", ":=", "gss", ".", "createSub", "(", "sub", ")", "\n", "gss", ".", "Unlock", "(", ...
// CreateSub records a new subscription represented by SubState. On success, // it records the subscription's ID in SubState.ID. This ID is to be used // by the other SubStore methods.
[ "CreateSub", "records", "a", "new", "subscription", "represented", "by", "SubState", ".", "On", "success", "it", "records", "the", "subscription", "s", "ID", "in", "SubState", ".", "ID", ".", "This", "ID", "is", "to", "be", "used", "by", "the", "other", ...
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L354-L359
26,675
nats-io/nats-streaming-server
stores/common.go
createSub
func (gss *genericSubStore) createSub(sub *spb.SubState) error { if gss.limits.MaxSubscriptions > 0 && len(gss.subs) >= gss.limits.MaxSubscriptions { return ErrTooManySubs } // Bump the max value before assigning it to the new subscription. gss.maxSubID++ // This new subscription has the max value. sub.ID = g...
go
func (gss *genericSubStore) createSub(sub *spb.SubState) error { if gss.limits.MaxSubscriptions > 0 && len(gss.subs) >= gss.limits.MaxSubscriptions { return ErrTooManySubs } // Bump the max value before assigning it to the new subscription. gss.maxSubID++ // This new subscription has the max value. sub.ID = g...
[ "func", "(", "gss", "*", "genericSubStore", ")", "createSub", "(", "sub", "*", "spb", ".", "SubState", ")", "error", "{", "if", "gss", ".", "limits", ".", "MaxSubscriptions", ">", "0", "&&", "len", "(", "gss", ".", "subs", ")", ">=", "gss", ".", "l...
// createSub checks that the number of subscriptions is below the max // and if so, assigns a new subscription ID and keep track of it in a map. // Lock is assumed to be held on entry.
[ "createSub", "checks", "that", "the", "number", "of", "subscriptions", "is", "below", "the", "max", "and", "if", "so", "assigns", "a", "new", "subscription", "ID", "and", "keep", "track", "of", "it", "in", "a", "map", ".", "Lock", "is", "assumed", "to", ...
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/stores/common.go#L369-L384
26,676
nats-io/nats-streaming-server
server/partitions.go
initPartitions
func (s *StanServer) initPartitions() error { // The option says that the server should only use the pre-defined channels, // but none was specified. Don't see the point in continuing... if len(s.opts.StoreLimits.PerChannel) == 0 { return ErrNoChannel } nc, err := s.createNatsClientConn("pc") if err != nil { ...
go
func (s *StanServer) initPartitions() error { // The option says that the server should only use the pre-defined channels, // but none was specified. Don't see the point in continuing... if len(s.opts.StoreLimits.PerChannel) == 0 { return ErrNoChannel } nc, err := s.createNatsClientConn("pc") if err != nil { ...
[ "func", "(", "s", "*", "StanServer", ")", "initPartitions", "(", ")", "error", "{", "// The option says that the server should only use the pre-defined channels,", "// but none was specified. Don't see the point in continuing...", "if", "len", "(", "s", ".", "opts", ".", "Sto...
// Initialize the channels partitions objects and issue the first // request to check if other servers in the cluster incorrectly have // any of the channel that this server is supposed to handle.
[ "Initialize", "the", "channels", "partitions", "objects", "and", "issue", "the", "first", "request", "to", "check", "if", "other", "servers", "in", "the", "cluster", "incorrectly", "have", "any", "of", "the", "channel", "that", "this", "server", "is", "suppose...
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/partitions.go#L64-L107
26,677
nats-io/nats-streaming-server
server/partitions.go
createChannelsMapAndSublist
func (p *partitions) createChannelsMapAndSublist(storeChannels map[string]*stores.ChannelLimits) { p.channels = make([]string, 0, len(storeChannels)) p.sl = util.NewSublist() for c := range storeChannels { p.channels = append(p.channels, c) // When creating the store, we have already checked that channel names ...
go
func (p *partitions) createChannelsMapAndSublist(storeChannels map[string]*stores.ChannelLimits) { p.channels = make([]string, 0, len(storeChannels)) p.sl = util.NewSublist() for c := range storeChannels { p.channels = append(p.channels, c) // When creating the store, we have already checked that channel names ...
[ "func", "(", "p", "*", "partitions", ")", "createChannelsMapAndSublist", "(", "storeChannels", "map", "[", "string", "]", "*", "stores", ".", "ChannelLimits", ")", "{", "p", ".", "channels", "=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "...
// Creates the channels map based on the store's PerChannel map that was given.
[ "Creates", "the", "channels", "map", "based", "on", "the", "store", "s", "PerChannel", "map", "that", "was", "given", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/partitions.go#L110-L119
26,678
nats-io/nats-streaming-server
server/partitions.go
topologyChanged
func (p *partitions) topologyChanged(_ *nats.Conn) { p.Lock() defer p.Unlock() if p.isShutdown { return } // Let's wait before checking (sending the list and waiting for a reply) // so that the new NATS Server has a chance to send its local // subscriptions to the rest of the cluster. That will reduce the risk...
go
func (p *partitions) topologyChanged(_ *nats.Conn) { p.Lock() defer p.Unlock() if p.isShutdown { return } // Let's wait before checking (sending the list and waiting for a reply) // so that the new NATS Server has a chance to send its local // subscriptions to the rest of the cluster. That will reduce the risk...
[ "func", "(", "p", "*", "partitions", ")", "topologyChanged", "(", "_", "*", "nats", ".", "Conn", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "if", "p", ".", "isShutdown", "{", "return", "\n", "}", "\...
// Topology changed. Sends the list of channels.
[ "Topology", "changed", ".", "Sends", "the", "list", "of", "channels", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/partitions.go#L122-L146
26,679
nats-io/nats-streaming-server
server/partitions.go
initSubscriptions
func (p *partitions) initSubscriptions() error { // NOTE: Use the server's nc connection here, not the partitions' one. for _, channelName := range p.channels { pubSubject := fmt.Sprintf("%s.%s", p.s.info.Publish, channelName) if _, err := p.s.nc.Subscribe(pubSubject, p.s.processClientPublish); err != nil { re...
go
func (p *partitions) initSubscriptions() error { // NOTE: Use the server's nc connection here, not the partitions' one. for _, channelName := range p.channels { pubSubject := fmt.Sprintf("%s.%s", p.s.info.Publish, channelName) if _, err := p.s.nc.Subscribe(pubSubject, p.s.processClientPublish); err != nil { re...
[ "func", "(", "p", "*", "partitions", ")", "initSubscriptions", "(", ")", "error", "{", "// NOTE: Use the server's nc connection here, not the partitions' one.", "for", "_", ",", "channelName", ":=", "range", "p", ".", "channels", "{", "pubSubject", ":=", "fmt", ".",...
// Create the internal subscriptions on the list of channels.
[ "Create", "the", "internal", "subscriptions", "on", "the", "list", "of", "channels", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/partitions.go#L149-L158
26,680
nats-io/nats-streaming-server
server/partitions.go
processChannelsListRequests
func (p *partitions) processChannelsListRequests(m *nats.Msg) { // Message cannot be empty, we are supposed to receive // a spb.CtrlMsg_Partitioning protocol. We should also // have a repy subject if len(m.Data) == 0 || m.Reply == "" { return } req := spb.CtrlMsg{} if err := req.Unmarshal(m.Data); err != nil {...
go
func (p *partitions) processChannelsListRequests(m *nats.Msg) { // Message cannot be empty, we are supposed to receive // a spb.CtrlMsg_Partitioning protocol. We should also // have a repy subject if len(m.Data) == 0 || m.Reply == "" { return } req := spb.CtrlMsg{} if err := req.Unmarshal(m.Data); err != nil {...
[ "func", "(", "p", "*", "partitions", ")", "processChannelsListRequests", "(", "m", "*", "nats", ".", "Msg", ")", "{", "// Message cannot be empty, we are supposed to receive", "// a spb.CtrlMsg_Partitioning protocol. We should also", "// have a repy subject", "if", "len", "("...
// Decode the incoming partitioning protocol message. // It can be an HB, in which case, if it is from a new server // we send our list to the cluster, or it can be a request // from another server. If so, we reply to the given inbox // with either an empty Data field or the name of the first // channel we have in comm...
[ "Decode", "the", "incoming", "partitioning", "protocol", "message", ".", "It", "can", "be", "an", "HB", "in", "which", "case", "if", "it", "is", "from", "a", "new", "server", "we", "send", "our", "list", "to", "the", "cluster", "or", "it", "can", "be",...
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/partitions.go#L196-L249
26,681
nats-io/nats-streaming-server
server/partitions.go
shutdown
func (p *partitions) shutdown() { p.Lock() defer p.Unlock() if p.isShutdown { return } p.isShutdown = true if p.nc != nil { p.nc.Close() } }
go
func (p *partitions) shutdown() { p.Lock() defer p.Unlock() if p.isShutdown { return } p.isShutdown = true if p.nc != nil { p.nc.Close() } }
[ "func", "(", "p", "*", "partitions", ")", "shutdown", "(", ")", "{", "p", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "Unlock", "(", ")", "\n", "if", "p", ".", "isShutdown", "{", "return", "\n", "}", "\n", "p", ".", "isShutdown", "=", "true...
// Notifies all go-routines used by partitioning code that the // server is shuting down and closes the internal NATS connection.
[ "Notifies", "all", "go", "-", "routines", "used", "by", "partitioning", "code", "that", "the", "server", "is", "shuting", "down", "and", "closes", "the", "internal", "NATS", "connection", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/partitions.go#L253-L263
26,682
nats-io/nats-streaming-server
server/conf.go
checkType
func checkType(name string, kind reflect.Kind, v interface{}) error { actualKind := reflect.TypeOf(v).Kind() if actualKind != kind { return fmt.Errorf("parameter %q value is expected to be %v, got %v", name, kind.String(), actualKind.String()) } return nil }
go
func checkType(name string, kind reflect.Kind, v interface{}) error { actualKind := reflect.TypeOf(v).Kind() if actualKind != kind { return fmt.Errorf("parameter %q value is expected to be %v, got %v", name, kind.String(), actualKind.String()) } return nil }
[ "func", "checkType", "(", "name", "string", ",", "kind", "reflect", ".", "Kind", ",", "v", "interface", "{", "}", ")", "error", "{", "actualKind", ":=", "reflect", ".", "TypeOf", "(", "v", ")", ".", "Kind", "(", ")", "\n", "if", "actualKind", "!=", ...
// checkType returns a formatted error if `v` is not of the expected kind.
[ "checkType", "returns", "a", "formatted", "error", "if", "v", "is", "not", "of", "the", "expected", "kind", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/conf.go#L179-L186
26,683
nats-io/nats-streaming-server
server/conf.go
parseTLS
func parseTLS(itf interface{}, opts *Options) error { m, ok := itf.(map[string]interface{}) if !ok { return fmt.Errorf("expected TLS to be a map/struct, got %v", itf) } for k, v := range m { name := strings.ToLower(k) switch name { case "client_cert": if err := checkType(k, reflect.String, v); err != nil...
go
func parseTLS(itf interface{}, opts *Options) error { m, ok := itf.(map[string]interface{}) if !ok { return fmt.Errorf("expected TLS to be a map/struct, got %v", itf) } for k, v := range m { name := strings.ToLower(k) switch name { case "client_cert": if err := checkType(k, reflect.String, v); err != nil...
[ "func", "parseTLS", "(", "itf", "interface", "{", "}", ",", "opts", "*", "Options", ")", "error", "{", "m", ",", "ok", ":=", "itf", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "!", "ok", "{", "return", "fmt", "....
// parseTLS updates `opts` with TLS config
[ "parseTLS", "updates", "opts", "with", "TLS", "config" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/conf.go#L189-L215
26,684
nats-io/nats-streaming-server
server/conf.go
parseStoreLimits
func parseStoreLimits(itf interface{}, opts *Options) error { m, ok := itf.(map[string]interface{}) if !ok { return fmt.Errorf("expected store limits to be a map/struct, got %v", itf) } for k, v := range m { name := strings.ToLower(k) switch name { case "mc", "max_channels", "maxchannels": if err := chec...
go
func parseStoreLimits(itf interface{}, opts *Options) error { m, ok := itf.(map[string]interface{}) if !ok { return fmt.Errorf("expected store limits to be a map/struct, got %v", itf) } for k, v := range m { name := strings.ToLower(k) switch name { case "mc", "max_channels", "maxchannels": if err := chec...
[ "func", "parseStoreLimits", "(", "itf", "interface", "{", "}", ",", "opts", "*", "Options", ")", "error", "{", "m", ",", "ok", ":=", "itf", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "!", "ok", "{", "return", "fm...
// parseStoreLimits updates `opts` with store limits
[ "parseStoreLimits", "updates", "opts", "with", "store", "limits" ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/conf.go#L306-L331
26,685
nats-io/nats-streaming-server
server/conf.go
parseChannelLimits
func parseChannelLimits(cl *stores.ChannelLimits, k, name string, v interface{}, isGlobal bool) error { switch name { case "msu", "max_subs", "max_subscriptions", "maxsubscriptions": if err := checkType(k, reflect.Int64, v); err != nil { return err } cl.MaxSubscriptions = int(v.(int64)) if !isGlobal && cl....
go
func parseChannelLimits(cl *stores.ChannelLimits, k, name string, v interface{}, isGlobal bool) error { switch name { case "msu", "max_subs", "max_subscriptions", "maxsubscriptions": if err := checkType(k, reflect.Int64, v); err != nil { return err } cl.MaxSubscriptions = int(v.(int64)) if !isGlobal && cl....
[ "func", "parseChannelLimits", "(", "cl", "*", "stores", ".", "ChannelLimits", ",", "k", ",", "name", "string", ",", "v", "interface", "{", "}", ",", "isGlobal", "bool", ")", "error", "{", "switch", "name", "{", "case", "\"", "\"", ",", "\"", "\"", ",...
// parseChannelLimits updates `cl` with channel limits.
[ "parseChannelLimits", "updates", "cl", "with", "channel", "limits", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/conf.go#L334-L386
26,686
nats-io/nats-streaming-server
server/conf.go
parsePerChannelLimits
func parsePerChannelLimits(itf interface{}, opts *Options) error { m, ok := itf.(map[string]interface{}) if !ok { return fmt.Errorf("expected per channel limits to be a map/struct, got %v", itf) } for channelName, limits := range m { limitsMap, ok := limits.(map[string]interface{}) if !ok { return fmt.Erro...
go
func parsePerChannelLimits(itf interface{}, opts *Options) error { m, ok := itf.(map[string]interface{}) if !ok { return fmt.Errorf("expected per channel limits to be a map/struct, got %v", itf) } for channelName, limits := range m { limitsMap, ok := limits.(map[string]interface{}) if !ok { return fmt.Erro...
[ "func", "parsePerChannelLimits", "(", "itf", "interface", "{", "}", ",", "opts", "*", "Options", ")", "error", "{", "m", ",", "ok", ":=", "itf", ".", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "!", "ok", "{", "return", ...
// parsePerChannelLimits updates `opts` with per channel limits.
[ "parsePerChannelLimits", "updates", "opts", "with", "per", "channel", "limits", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/conf.go#L389-L413
26,687
nats-io/nats-streaming-server
server/conf.go
getBytes
func getBytes(f *flag.Flag) (int64, error) { var res map[string]interface{} // Use NATS parser to do the conversion for us. res, err := conf.Parse(fmt.Sprintf("bytes: %v", f.Value.String())) if err != nil { return 0, err } resVal := res["bytes"] if resVal == nil || reflect.TypeOf(resVal).Kind() != reflect.Int6...
go
func getBytes(f *flag.Flag) (int64, error) { var res map[string]interface{} // Use NATS parser to do the conversion for us. res, err := conf.Parse(fmt.Sprintf("bytes: %v", f.Value.String())) if err != nil { return 0, err } resVal := res["bytes"] if resVal == nil || reflect.TypeOf(resVal).Kind() != reflect.Int6...
[ "func", "getBytes", "(", "f", "*", "flag", ".", "Flag", ")", "(", "int64", ",", "error", ")", "{", "var", "res", "map", "[", "string", "]", "interface", "{", "}", "\n", "// Use NATS parser to do the conversion for us.", "res", ",", "err", ":=", "conf", "...
// getBytes returns the number of bytes from the flag's String size. // For instance, 1KB would return 1024.
[ "getBytes", "returns", "the", "number", "of", "bytes", "from", "the", "flag", "s", "String", "size", ".", "For", "instance", "1KB", "would", "return", "1024", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/conf.go#L703-L715
26,688
nats-io/nats-streaming-server
util/sublist.go
addToCache
func (s *Sublist) addToCache(subject string, element interface{}) { for k, r := range s.cache { if matchLiteral(k, subject) { // Copy since others may have a reference. nr := append([]interface{}(nil), r...) nr = append(nr, element) s.cache[k] = nr } } }
go
func (s *Sublist) addToCache(subject string, element interface{}) { for k, r := range s.cache { if matchLiteral(k, subject) { // Copy since others may have a reference. nr := append([]interface{}(nil), r...) nr = append(nr, element) s.cache[k] = nr } } }
[ "func", "(", "s", "*", "Sublist", ")", "addToCache", "(", "subject", "string", ",", "element", "interface", "{", "}", ")", "{", "for", "k", ",", "r", ":=", "range", "s", ".", "cache", "{", "if", "matchLiteral", "(", "k", ",", "subject", ")", "{", ...
// addToCache will add the new entry to existing cache // entries if needed. Assumes write lock is held.
[ "addToCache", "will", "add", "the", "new", "entry", "to", "existing", "cache", "entries", "if", "needed", ".", "Assumes", "write", "lock", "is", "held", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L139-L148
26,689
nats-io/nats-streaming-server
util/sublist.go
removeFromCache
func (s *Sublist) removeFromCache(subject string) { for k := range s.cache { if !matchLiteral(k, subject) { continue } // Since someone else may be referencing, can't modify the list // safely, just let it re-populate. delete(s.cache, k) } }
go
func (s *Sublist) removeFromCache(subject string) { for k := range s.cache { if !matchLiteral(k, subject) { continue } // Since someone else may be referencing, can't modify the list // safely, just let it re-populate. delete(s.cache, k) } }
[ "func", "(", "s", "*", "Sublist", ")", "removeFromCache", "(", "subject", "string", ")", "{", "for", "k", ":=", "range", "s", ".", "cache", "{", "if", "!", "matchLiteral", "(", "k", ",", "subject", ")", "{", "continue", "\n", "}", "\n", "// Since som...
// removeFromCache will remove any active cache entries on that subject. // Assumes write lock is held.
[ "removeFromCache", "will", "remove", "any", "active", "cache", "entries", "on", "that", "subject", ".", "Assumes", "write", "lock", "is", "held", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L152-L161
26,690
nats-io/nats-streaming-server
util/sublist.go
Match
func (s *Sublist) Match(subject string) []interface{} { s.RLock() rc, ok := s.cache[subject] s.RUnlock() if ok { return rc } tsa := [32]string{} tokens := tsa[:0] start := 0 for i := 0; i < len(subject); i++ { if subject[i] == btsep { tokens = append(tokens, subject[start:i]) start = i + 1 } } t...
go
func (s *Sublist) Match(subject string) []interface{} { s.RLock() rc, ok := s.cache[subject] s.RUnlock() if ok { return rc } tsa := [32]string{} tokens := tsa[:0] start := 0 for i := 0; i < len(subject); i++ { if subject[i] == btsep { tokens = append(tokens, subject[start:i]) start = i + 1 } } t...
[ "func", "(", "s", "*", "Sublist", ")", "Match", "(", "subject", "string", ")", "[", "]", "interface", "{", "}", "{", "s", ".", "RLock", "(", ")", "\n", "rc", ",", "ok", ":=", "s", ".", "cache", "[", "subject", "]", "\n", "s", ".", "RUnlock", ...
// Match will match all entries to the literal subject. // It will return a set of results.
[ "Match", "will", "match", "all", "entries", "to", "the", "literal", "subject", ".", "It", "will", "return", "a", "set", "of", "results", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L165-L200
26,691
nats-io/nats-streaming-server
util/sublist.go
Remove
func (s *Sublist) Remove(subject string, element interface{}) error { tsa := [32]string{} tokens := tsa[:0] start := 0 for i := 0; i < len(subject); i++ { if subject[i] == btsep { tokens = append(tokens, subject[start:i]) start = i + 1 } } tokens = append(tokens, subject[start:]) s.Lock() defer s.Unl...
go
func (s *Sublist) Remove(subject string, element interface{}) error { tsa := [32]string{} tokens := tsa[:0] start := 0 for i := 0; i < len(subject); i++ { if subject[i] == btsep { tokens = append(tokens, subject[start:i]) start = i + 1 } } tokens = append(tokens, subject[start:]) s.Lock() defer s.Unl...
[ "func", "(", "s", "*", "Sublist", ")", "Remove", "(", "subject", "string", ",", "element", "interface", "{", "}", ")", "error", "{", "tsa", ":=", "[", "32", "]", "string", "{", "}", "\n", "tokens", ":=", "tsa", "[", ":", "0", "]", "\n", "start", ...
// Remove will remove an element from the sublist.
[ "Remove", "will", "remove", "an", "element", "from", "the", "sublist", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L238-L296
26,692
nats-io/nats-streaming-server
util/sublist.go
removeFromList
func removeFromList(element interface{}, l []interface{}) ([]interface{}, bool) { for i := 0; i < len(l); i++ { if l[i] == element { last := len(l) - 1 l[i] = l[last] l[last] = nil l = l[:last] return shrinkAsNeeded(l), true } } return l, false }
go
func removeFromList(element interface{}, l []interface{}) ([]interface{}, bool) { for i := 0; i < len(l); i++ { if l[i] == element { last := len(l) - 1 l[i] = l[last] l[last] = nil l = l[:last] return shrinkAsNeeded(l), true } } return l, false }
[ "func", "removeFromList", "(", "element", "interface", "{", "}", ",", "l", "[", "]", "interface", "{", "}", ")", "(", "[", "]", "interface", "{", "}", ",", "bool", ")", "{", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "l", ")", ";", "i"...
// Removes an element from a list.
[ "Removes", "an", "element", "from", "a", "list", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L336-L347
26,693
nats-io/nats-streaming-server
util/sublist.go
shrinkAsNeeded
func shrinkAsNeeded(l []interface{}) []interface{} { ll := len(l) cl := cap(l) // Don't bother if list not too big if cl <= 8 { return l } pFree := float32(cl-ll) / float32(cl) if pFree > 0.50 { return append([]interface{}(nil), l...) } return l }
go
func shrinkAsNeeded(l []interface{}) []interface{} { ll := len(l) cl := cap(l) // Don't bother if list not too big if cl <= 8 { return l } pFree := float32(cl-ll) / float32(cl) if pFree > 0.50 { return append([]interface{}(nil), l...) } return l }
[ "func", "shrinkAsNeeded", "(", "l", "[", "]", "interface", "{", "}", ")", "[", "]", "interface", "{", "}", "{", "ll", ":=", "len", "(", "l", ")", "\n", "cl", ":=", "cap", "(", "l", ")", "\n", "// Don't bother if list not too big", "if", "cl", "<=", ...
// Checks if we need to do a resize. This is for very large growth then // subsequent return to a more normal size from unsubscribe.
[ "Checks", "if", "we", "need", "to", "do", "a", "resize", ".", "This", "is", "for", "very", "large", "growth", "then", "subsequent", "return", "to", "a", "more", "normal", "size", "from", "unsubscribe", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L360-L372
26,694
nats-io/nats-streaming-server
util/sublist.go
CacheCount
func (s *Sublist) CacheCount() int { s.RLock() defer s.RUnlock() return len(s.cache) }
go
func (s *Sublist) CacheCount() int { s.RLock() defer s.RUnlock() return len(s.cache) }
[ "func", "(", "s", "*", "Sublist", ")", "CacheCount", "(", ")", "int", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "return", "len", "(", "s", ".", "cache", ")", "\n", "}" ]
// CacheCount returns the number of result sets in the cache.
[ "CacheCount", "returns", "the", "number", "of", "result", "sets", "in", "the", "cache", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/util/sublist.go#L382-L386
26,695
nats-io/nats-streaming-server
server/server.go
startDeleteTimer
func (c *channel) startDeleteTimer() { c.activity.last = time.Now() c.resetDeleteTimer(c.activity.maxInactivity) }
go
func (c *channel) startDeleteTimer() { c.activity.last = time.Now() c.resetDeleteTimer(c.activity.maxInactivity) }
[ "func", "(", "c", "*", "channel", ")", "startDeleteTimer", "(", ")", "{", "c", ".", "activity", ".", "last", "=", "time", ".", "Now", "(", ")", "\n", "c", ".", "resetDeleteTimer", "(", "c", ".", "activity", ".", "maxInactivity", ")", "\n", "}" ]
// Starts the delete timer that when firing will post // a channel delete request to the ioLoop. // The channelStore's mutex must be held on entry.
[ "Starts", "the", "delete", "timer", "that", "when", "firing", "will", "post", "a", "channel", "delete", "request", "to", "the", "ioLoop", ".", "The", "channelStore", "s", "mutex", "must", "be", "held", "on", "entry", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/server.go#L453-L456
26,696
nats-io/nats-streaming-server
server/server.go
stopDeleteTimer
func (c *channel) stopDeleteTimer() { if c.activity.timer != nil { c.activity.timer.Stop() c.activity.timerSet = false if c.stan.debug { c.stan.log.Debugf("Channel %q delete timer stopped", c.name) } } }
go
func (c *channel) stopDeleteTimer() { if c.activity.timer != nil { c.activity.timer.Stop() c.activity.timerSet = false if c.stan.debug { c.stan.log.Debugf("Channel %q delete timer stopped", c.name) } } }
[ "func", "(", "c", "*", "channel", ")", "stopDeleteTimer", "(", ")", "{", "if", "c", ".", "activity", ".", "timer", "!=", "nil", "{", "c", ".", "activity", ".", "timer", ".", "Stop", "(", ")", "\n", "c", ".", "activity", ".", "timerSet", "=", "fal...
// Stops the delete timer. // The channelStore's mutex must be held on entry.
[ "Stops", "the", "delete", "timer", ".", "The", "channelStore", "s", "mutex", "must", "be", "held", "on", "entry", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/server.go#L460-L468
26,697
nats-io/nats-streaming-server
server/server.go
resetDeleteTimer
func (c *channel) resetDeleteTimer(newDuration time.Duration) { a := c.activity if a.timer == nil { a.timer = time.AfterFunc(newDuration, func() { c.stan.sendDeleteChannelRequest(c) }) } else { a.timer.Reset(newDuration) } if c.stan.debug { c.stan.log.Debugf("Channel %q delete timer set to fire in %v", ...
go
func (c *channel) resetDeleteTimer(newDuration time.Duration) { a := c.activity if a.timer == nil { a.timer = time.AfterFunc(newDuration, func() { c.stan.sendDeleteChannelRequest(c) }) } else { a.timer.Reset(newDuration) } if c.stan.debug { c.stan.log.Debugf("Channel %q delete timer set to fire in %v", ...
[ "func", "(", "c", "*", "channel", ")", "resetDeleteTimer", "(", "newDuration", "time", ".", "Duration", ")", "{", "a", ":=", "c", ".", "activity", "\n", "if", "a", ".", "timer", "==", "nil", "{", "a", ".", "timer", "=", "time", ".", "AfterFunc", "(...
// Resets the delete timer to the given duration. // If the timer was not created, this call will create it. // The channelStore's mutex must be held on entry.
[ "Resets", "the", "delete", "timer", "to", "the", "given", "duration", ".", "If", "the", "timer", "was", "not", "created", "this", "call", "will", "create", "it", ".", "The", "channelStore", "s", "mutex", "must", "be", "held", "on", "entry", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/server.go#L473-L486
26,698
nats-io/nats-streaming-server
server/server.go
pubMsgToMsgProto
func (c *channel) pubMsgToMsgProto(pm *pb.PubMsg, seq uint64) *pb.MsgProto { m := &pb.MsgProto{ Sequence: seq, Subject: pm.Subject, Reply: pm.Reply, Data: pm.Data, Timestamp: time.Now().UnixNano(), } if c.lTimestamp > 0 && m.Timestamp < c.lTimestamp { m.Timestamp = c.lTimestamp } c.lTimesta...
go
func (c *channel) pubMsgToMsgProto(pm *pb.PubMsg, seq uint64) *pb.MsgProto { m := &pb.MsgProto{ Sequence: seq, Subject: pm.Subject, Reply: pm.Reply, Data: pm.Data, Timestamp: time.Now().UnixNano(), } if c.lTimestamp > 0 && m.Timestamp < c.lTimestamp { m.Timestamp = c.lTimestamp } c.lTimesta...
[ "func", "(", "c", "*", "channel", ")", "pubMsgToMsgProto", "(", "pm", "*", "pb", ".", "PubMsg", ",", "seq", "uint64", ")", "*", "pb", ".", "MsgProto", "{", "m", ":=", "&", "pb", ".", "MsgProto", "{", "Sequence", ":", "seq", ",", "Subject", ":", "...
// pubMsgToMsgProto converts a PubMsg to a MsgProto and assigns a timestamp // which is monotonic with respect to the channel.
[ "pubMsgToMsgProto", "converts", "a", "PubMsg", "to", "a", "MsgProto", "and", "assigns", "a", "timestamp", "which", "is", "monotonic", "with", "respect", "to", "the", "channel", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/server.go#L490-L503
26,699
nats-io/nats-streaming-server
server/server.go
subToSnapshotRestoreRequests
func (s *StanServer) subToSnapshotRestoreRequests() error { var ( msgBuf []byte buf []byte snapshotRestorePrefix = fmt.Sprintf("%s.%s.", defaultSnapshotPrefix, s.info.ClusterID) prefixLen = len(snapshotRestorePrefix) ) sub, err := s.ncsr.Subscribe(snapshotRestoreP...
go
func (s *StanServer) subToSnapshotRestoreRequests() error { var ( msgBuf []byte buf []byte snapshotRestorePrefix = fmt.Sprintf("%s.%s.", defaultSnapshotPrefix, s.info.ClusterID) prefixLen = len(snapshotRestorePrefix) ) sub, err := s.ncsr.Subscribe(snapshotRestoreP...
[ "func", "(", "s", "*", "StanServer", ")", "subToSnapshotRestoreRequests", "(", ")", "error", "{", "var", "(", "msgBuf", "[", "]", "byte", "\n", "buf", "[", "]", "byte", "\n", "snapshotRestorePrefix", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d...
// Sets a subscription that will handle snapshot restore requests from followers.
[ "Sets", "a", "subscription", "that", "will", "handle", "snapshot", "restore", "requests", "from", "followers", "." ]
57c6c84265c0012a1efef365703c221329804d4c
https://github.com/nats-io/nats-streaming-server/blob/57c6c84265c0012a1efef365703c221329804d4c/server/server.go#L506-L564