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
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
164,100
brocaar/loraserver
internal/storage/multicast_group.go
GetSchedulableMulticastQueueItems
func GetSchedulableMulticastQueueItems(db sqlx.Ext, count int) ([]MulticastQueueItem, error) { var items []MulticastQueueItem err := sqlx.Select(db, &items, ` select * from multicast_queue where schedule_at <= $2 order by id limit $1 for update skip locked `, count, time.Now()) if err != nil...
go
func GetSchedulableMulticastQueueItems(db sqlx.Ext, count int) ([]MulticastQueueItem, error) { var items []MulticastQueueItem err := sqlx.Select(db, &items, ` select * from multicast_queue where schedule_at <= $2 order by id limit $1 for update skip locked `, count, time.Now()) if err != nil...
[ "func", "GetSchedulableMulticastQueueItems", "(", "db", "sqlx", ".", "Ext", ",", "count", "int", ")", "(", "[", "]", "MulticastQueueItem", ",", "error", ")", "{", "var", "items", "[", "]", "MulticastQueueItem", "\n", "err", ":=", "sqlx", ".", "Select", "("...
// GetSchedulableMulticastQueueItems returns a slice of multicast-queue items // for scheduling. // The returned queue-items will be locked for update so that this query can // be executed in parallel.
[ "GetSchedulableMulticastQueueItems", "returns", "a", "slice", "of", "multicast", "-", "queue", "items", "for", "scheduling", ".", "The", "returned", "queue", "-", "items", "will", "be", "locked", "for", "update", "so", "that", "this", "query", "can", "be", "ex...
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/multicast_group.go#L332-L351
164,101
brocaar/loraserver
internal/storage/multicast_group.go
GetMaxScheduleAtForMulticastGroup
func GetMaxScheduleAtForMulticastGroup(db sqlx.Queryer, multicastGroupID uuid.UUID) (time.Time, error) { ts := new(time.Time) err := sqlx.Get(db, &ts, ` select max(schedule_at) from multicast_queue where multicast_group_id = $1 `, multicastGroupID) if err != nil { return time.Time{}, handlePSQLErr...
go
func GetMaxScheduleAtForMulticastGroup(db sqlx.Queryer, multicastGroupID uuid.UUID) (time.Time, error) { ts := new(time.Time) err := sqlx.Get(db, &ts, ` select max(schedule_at) from multicast_queue where multicast_group_id = $1 `, multicastGroupID) if err != nil { return time.Time{}, handlePSQLErr...
[ "func", "GetMaxScheduleAtForMulticastGroup", "(", "db", "sqlx", ".", "Queryer", ",", "multicastGroupID", "uuid", ".", "UUID", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "ts", ":=", "new", "(", "time", ".", "Time", ")", "\n\n", "err", ":=", ...
// GetMaxScheduleAtForMulticastGroup returns the maximum schedule at timestamp // for the given multicast-group.
[ "GetMaxScheduleAtForMulticastGroup", "returns", "the", "maximum", "schedule", "at", "timestamp", "for", "the", "given", "multicast", "-", "group", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/multicast_group.go#L374-L393
164,102
brocaar/loraserver
internal/gateway/gateway.go
Start
func (s *StatsHandler) Start() error { go func() { s.wg.Add(1) defer s.wg.Done() for stats := range gateway.Backend().StatsPacketChan() { go func(stats gw.GatewayStats) { s.wg.Add(1) defer s.wg.Done() if err := updateGatewayState(storage.DB(), storage.RedisPool(), stats); err != nil { log.W...
go
func (s *StatsHandler) Start() error { go func() { s.wg.Add(1) defer s.wg.Done() for stats := range gateway.Backend().StatsPacketChan() { go func(stats gw.GatewayStats) { s.wg.Add(1) defer s.wg.Done() if err := updateGatewayState(storage.DB(), storage.RedisPool(), stats); err != nil { log.W...
[ "func", "(", "s", "*", "StatsHandler", ")", "Start", "(", ")", "error", "{", "go", "func", "(", ")", "{", "s", ".", "wg", ".", "Add", "(", "1", ")", "\n", "defer", "s", ".", "wg", ".", "Done", "(", ")", "\n\n", "for", "stats", ":=", "range", ...
// Start starts the stats handler.
[ "Start", "starts", "the", "stats", "handler", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/gateway/gateway.go#L37-L58
164,103
brocaar/loraserver
internal/uplink/data/data.go
Handle
func Handle(rxPacket models.RXPacket) error { ctx := dataContext{ RXPacket: rxPacket, } for _, t := range tasks { if err := t(&ctx); err != nil { return err } } return nil }
go
func Handle(rxPacket models.RXPacket) error { ctx := dataContext{ RXPacket: rxPacket, } for _, t := range tasks { if err := t(&ctx); err != nil { return err } } return nil }
[ "func", "Handle", "(", "rxPacket", "models", ".", "RXPacket", ")", "error", "{", "ctx", ":=", "dataContext", "{", "RXPacket", ":", "rxPacket", ",", "}", "\n\n", "for", "_", ",", "t", ":=", "range", "tasks", "{", "if", "err", ":=", "t", "(", "&", "c...
// Handle handles an uplink data frame
[ "Handle", "handles", "an", "uplink", "data", "frame" ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/uplink/data/data.go#L83-L95
164,104
brocaar/loraserver
internal/uplink/data/data.go
sendRXInfoPayload
func sendRXInfoPayload(ds storage.DeviceSession, rxPacket models.RXPacket) error { rxInfoReq := nc.HandleUplinkMetaDataRequest{ DevEui: ds.DevEUI[:], TxInfo: rxPacket.TXInfo, RxInfo: rxPacket.RXInfoSet, } _, err := controller.Client().HandleUplinkMetaData(context.Background(), &rxInfoReq) if err != nil { r...
go
func sendRXInfoPayload(ds storage.DeviceSession, rxPacket models.RXPacket) error { rxInfoReq := nc.HandleUplinkMetaDataRequest{ DevEui: ds.DevEUI[:], TxInfo: rxPacket.TXInfo, RxInfo: rxPacket.RXInfoSet, } _, err := controller.Client().HandleUplinkMetaData(context.Background(), &rxInfoReq) if err != nil { r...
[ "func", "sendRXInfoPayload", "(", "ds", "storage", ".", "DeviceSession", ",", "rxPacket", "models", ".", "RXPacket", ")", "error", "{", "rxInfoReq", ":=", "nc", ".", "HandleUplinkMetaDataRequest", "{", "DevEui", ":", "ds", ".", "DevEUI", "[", ":", "]", ",", ...
// sendRXInfoPayload sends the rx and tx meta-data to the network controller.
[ "sendRXInfoPayload", "sends", "the", "rx", "and", "tx", "meta", "-", "data", "to", "the", "network", "controller", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/uplink/data/data.go#L586-L601
164,105
brocaar/loraserver
internal/storage/gateway_profile.go
GetVersion
func (p GatewayProfile) GetVersion() string { return p.UpdatedAt.UTC().Format(time.RFC3339Nano) }
go
func (p GatewayProfile) GetVersion() string { return p.UpdatedAt.UTC().Format(time.RFC3339Nano) }
[ "func", "(", "p", "GatewayProfile", ")", "GetVersion", "(", ")", "string", "{", "return", "p", ".", "UpdatedAt", ".", "UTC", "(", ")", ".", "Format", "(", "time", ".", "RFC3339Nano", ")", "\n", "}" ]
// GetVersion returns the gateway-profile version.
[ "GetVersion", "returns", "the", "gateway", "-", "profile", "version", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/gateway_profile.go#L38-L40
164,106
brocaar/loraserver
internal/storage/gateway_profile.go
CreateGatewayProfile
func CreateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error { now := time.Now() c.CreatedAt = now c.UpdatedAt = now if c.ID == uuid.Nil { var err error c.ID, err = uuid.NewV4() if err != nil { return errors.Wrap(err, "new uuid v4 error") } } _, err := db.Exec(` insert into gateway_profile ( ...
go
func CreateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error { now := time.Now() c.CreatedAt = now c.UpdatedAt = now if c.ID == uuid.Nil { var err error c.ID, err = uuid.NewV4() if err != nil { return errors.Wrap(err, "new uuid v4 error") } } _, err := db.Exec(` insert into gateway_profile ( ...
[ "func", "CreateGatewayProfile", "(", "db", "sqlx", ".", "Execer", ",", "c", "*", "GatewayProfile", ")", "error", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "c", ".", "CreatedAt", "=", "now", "\n", "c", ".", "UpdatedAt", "=", "now", "\n\n",...
// CreateGatewayProfile creates the given gateway-profile. // As this will execute multiple SQL statements, it is recommended to perform // this within a transaction.
[ "CreateGatewayProfile", "creates", "the", "given", "gateway", "-", "profile", ".", "As", "this", "will", "execute", "multiple", "SQL", "statements", "it", "is", "recommended", "to", "perform", "this", "within", "a", "transaction", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/gateway_profile.go#L45-L101
164,107
brocaar/loraserver
internal/storage/gateway_profile.go
GetGatewayProfile
func GetGatewayProfile(db sqlx.Queryer, id uuid.UUID) (GatewayProfile, error) { var c GatewayProfile err := db.QueryRowx(` select gateway_profile_id, created_at, updated_at, channels from gateway_profile where gateway_profile_id = $1`, id, ).Scan( &c.ID, &c.CreatedAt, &c.UpdatedAt, pq....
go
func GetGatewayProfile(db sqlx.Queryer, id uuid.UUID) (GatewayProfile, error) { var c GatewayProfile err := db.QueryRowx(` select gateway_profile_id, created_at, updated_at, channels from gateway_profile where gateway_profile_id = $1`, id, ).Scan( &c.ID, &c.CreatedAt, &c.UpdatedAt, pq....
[ "func", "GetGatewayProfile", "(", "db", "sqlx", ".", "Queryer", ",", "id", "uuid", ".", "UUID", ")", "(", "GatewayProfile", ",", "error", ")", "{", "var", "c", "GatewayProfile", "\n", "err", ":=", "db", ".", "QueryRowx", "(", "`\n\t\tselect\n\t\t\tgateway_pr...
// GetGatewayProfile returns the gateway-profile matching the // given ID.
[ "GetGatewayProfile", "returns", "the", "gateway", "-", "profile", "matching", "the", "given", "ID", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/gateway_profile.go#L105-L161
164,108
brocaar/loraserver
internal/storage/gateway_profile.go
UpdateGatewayProfile
func UpdateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error { c.UpdatedAt = time.Now() res, err := db.Exec(` update gateway_profile set updated_at = $2, channels = $3 where gateway_profile_id = $1`, c.ID, c.UpdatedAt, pq.Array(c.Channels), ) if err != nil { return handlePSQLError(err, ...
go
func UpdateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error { c.UpdatedAt = time.Now() res, err := db.Exec(` update gateway_profile set updated_at = $2, channels = $3 where gateway_profile_id = $1`, c.ID, c.UpdatedAt, pq.Array(c.Channels), ) if err != nil { return handlePSQLError(err, ...
[ "func", "UpdateGatewayProfile", "(", "db", "sqlx", ".", "Execer", ",", "c", "*", "GatewayProfile", ")", "error", "{", "c", ".", "UpdatedAt", "=", "time", ".", "Now", "(", ")", "\n", "res", ",", "err", ":=", "db", ".", "Exec", "(", "`\n\t\tupdate gatewa...
// UpdateGatewayProfile updates the given gateway-profile. // As this will execute multiple SQL statements, it is recommended to perform // this within a transaction.
[ "UpdateGatewayProfile", "updates", "the", "given", "gateway", "-", "profile", ".", "As", "this", "will", "execute", "multiple", "SQL", "statements", "it", "is", "recommended", "to", "perform", "this", "within", "a", "transaction", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/gateway_profile.go#L166-L231
164,109
brocaar/loraserver
internal/maccommand/link_adr.go
handleLinkADRAns
func handleLinkADRAns(ds *storage.DeviceSession, block storage.MACCommandBlock, pendingBlock *storage.MACCommandBlock) ([]storage.MACCommandBlock, error) { if len(block.MACCommands) == 0 { return nil, errors.New("at least 1 mac-command expected, got none") } if pendingBlock == nil || len(pendingBlock.MACCommands)...
go
func handleLinkADRAns(ds *storage.DeviceSession, block storage.MACCommandBlock, pendingBlock *storage.MACCommandBlock) ([]storage.MACCommandBlock, error) { if len(block.MACCommands) == 0 { return nil, errors.New("at least 1 mac-command expected, got none") } if pendingBlock == nil || len(pendingBlock.MACCommands)...
[ "func", "handleLinkADRAns", "(", "ds", "*", "storage", ".", "DeviceSession", ",", "block", "storage", ".", "MACCommandBlock", ",", "pendingBlock", "*", "storage", ".", "MACCommandBlock", ")", "(", "[", "]", "storage", ".", "MACCommandBlock", ",", "error", ")",...
// handleLinkADRAns handles the ack of an ADR request
[ "handleLinkADRAns", "handles", "the", "ack", "of", "an", "ADR", "request" ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/maccommand/link_adr.go#L14-L103
164,110
brocaar/loraserver
internal/uplink/uplink.go
Start
func (s *Server) Start() error { go func() { s.wg.Add(1) defer s.wg.Done() HandleRXPackets(&s.wg) }() go func() { s.wg.Add(1) defer s.wg.Done() HandleDownlinkTXAcks(&s.wg) }() return nil }
go
func (s *Server) Start() error { go func() { s.wg.Add(1) defer s.wg.Done() HandleRXPackets(&s.wg) }() go func() { s.wg.Add(1) defer s.wg.Done() HandleDownlinkTXAcks(&s.wg) }() return nil }
[ "func", "(", "s", "*", "Server", ")", "Start", "(", ")", "error", "{", "go", "func", "(", ")", "{", "s", ".", "wg", ".", "Add", "(", "1", ")", "\n", "defer", "s", ".", "wg", ".", "Done", "(", ")", "\n", "HandleRXPackets", "(", "&", "s", "."...
// Start starts the server.
[ "Start", "starts", "the", "server", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/uplink/uplink.go#L62-L75
164,111
brocaar/loraserver
internal/uplink/uplink.go
Stop
func (s *Server) Stop() error { if err := gwbackend.Backend().Close(); err != nil { return fmt.Errorf("close gateway backend error: %s", err) } log.Info("waiting for pending actions to complete") s.wg.Wait() return nil }
go
func (s *Server) Stop() error { if err := gwbackend.Backend().Close(); err != nil { return fmt.Errorf("close gateway backend error: %s", err) } log.Info("waiting for pending actions to complete") s.wg.Wait() return nil }
[ "func", "(", "s", "*", "Server", ")", "Stop", "(", ")", "error", "{", "if", "err", ":=", "gwbackend", ".", "Backend", "(", ")", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ...
// Stop closes the gateway backend and waits for the server to complete the // pending packets.
[ "Stop", "closes", "the", "gateway", "backend", "and", "waits", "for", "the", "server", "to", "complete", "the", "pending", "packets", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/uplink/uplink.go#L79-L86
164,112
brocaar/loraserver
internal/uplink/uplink.go
HandleRXPackets
func HandleRXPackets(wg *sync.WaitGroup) { for uplinkFrame := range gwbackend.Backend().RXPacketChan() { go func(uplinkFrame gw.UplinkFrame) { wg.Add(1) defer wg.Done() if err := HandleRXPacket(uplinkFrame); err != nil { data := base64.StdEncoding.EncodeToString(uplinkFrame.PhyPayload) log.WithField...
go
func HandleRXPackets(wg *sync.WaitGroup) { for uplinkFrame := range gwbackend.Backend().RXPacketChan() { go func(uplinkFrame gw.UplinkFrame) { wg.Add(1) defer wg.Done() if err := HandleRXPacket(uplinkFrame); err != nil { data := base64.StdEncoding.EncodeToString(uplinkFrame.PhyPayload) log.WithField...
[ "func", "HandleRXPackets", "(", "wg", "*", "sync", ".", "WaitGroup", ")", "{", "for", "uplinkFrame", ":=", "range", "gwbackend", ".", "Backend", "(", ")", ".", "RXPacketChan", "(", ")", "{", "go", "func", "(", "uplinkFrame", "gw", ".", "UplinkFrame", ")"...
// HandleRXPackets consumes received packets by the gateway and handles them // in a separate go-routine. Errors are logged.
[ "HandleRXPackets", "consumes", "received", "packets", "by", "the", "gateway", "and", "handles", "them", "in", "a", "separate", "go", "-", "routine", ".", "Errors", "are", "logged", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/uplink/uplink.go#L90-L101
164,113
brocaar/loraserver
internal/uplink/uplink.go
HandleDownlinkTXAcks
func HandleDownlinkTXAcks(wg *sync.WaitGroup) { for downlinkTXAck := range gwbackend.Backend().DownlinkTXAckChan() { go func(downlinkTXAck gw.DownlinkTXAck) { wg.Add(1) defer wg.Done() if err := ack.HandleDownlinkTXAck(downlinkTXAck); err != nil { log.WithFields(log.Fields{ "gateway_id": hex.Encode...
go
func HandleDownlinkTXAcks(wg *sync.WaitGroup) { for downlinkTXAck := range gwbackend.Backend().DownlinkTXAckChan() { go func(downlinkTXAck gw.DownlinkTXAck) { wg.Add(1) defer wg.Done() if err := ack.HandleDownlinkTXAck(downlinkTXAck); err != nil { log.WithFields(log.Fields{ "gateway_id": hex.Encode...
[ "func", "HandleDownlinkTXAcks", "(", "wg", "*", "sync", ".", "WaitGroup", ")", "{", "for", "downlinkTXAck", ":=", "range", "gwbackend", ".", "Backend", "(", ")", ".", "DownlinkTXAckChan", "(", ")", "{", "go", "func", "(", "downlinkTXAck", "gw", ".", "Downl...
// HandleDownlinkTXAcks consumes received downlink tx acknowledgements from // the gateway.
[ "HandleDownlinkTXAcks", "consumes", "received", "downlink", "tx", "acknowledgements", "from", "the", "gateway", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/uplink/uplink.go#L110-L124
164,114
brocaar/loraserver
internal/downlink/scheduler.go
DeviceQueueSchedulerLoop
func DeviceQueueSchedulerLoop() { for { log.Debug("running class-b / class-c scheduler batch") if err := ScheduleDeviceQueueBatch(schedulerBatchSize); err != nil { log.WithError(err).Error("class-b / class-c scheduler error") } time.Sleep(schedulerInterval) } }
go
func DeviceQueueSchedulerLoop() { for { log.Debug("running class-b / class-c scheduler batch") if err := ScheduleDeviceQueueBatch(schedulerBatchSize); err != nil { log.WithError(err).Error("class-b / class-c scheduler error") } time.Sleep(schedulerInterval) } }
[ "func", "DeviceQueueSchedulerLoop", "(", ")", "{", "for", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "ScheduleDeviceQueueBatch", "(", "schedulerBatchSize", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "er...
// DeviceQueueSchedulerLoop starts an infinit loop calling the scheduler loop for Class-B // and Class-C sheduling.
[ "DeviceQueueSchedulerLoop", "starts", "an", "infinit", "loop", "calling", "the", "scheduler", "loop", "for", "Class", "-", "B", "and", "Class", "-", "C", "sheduling", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/downlink/scheduler.go#L17-L25
164,115
brocaar/loraserver
internal/downlink/scheduler.go
MulticastQueueSchedulerLoop
func MulticastQueueSchedulerLoop() { for { log.Debug("running multicast scheduler batch") if err := ScheduleMulticastQueueBatch(schedulerBatchSize); err != nil { log.WithError(err).Error("multicast scheduler error") } time.Sleep(schedulerInterval) } }
go
func MulticastQueueSchedulerLoop() { for { log.Debug("running multicast scheduler batch") if err := ScheduleMulticastQueueBatch(schedulerBatchSize); err != nil { log.WithError(err).Error("multicast scheduler error") } time.Sleep(schedulerInterval) } }
[ "func", "MulticastQueueSchedulerLoop", "(", ")", "{", "for", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "ScheduleMulticastQueueBatch", "(", "schedulerBatchSize", ")", ";", "err", "!=", "nil", "{", "log", ".", "WithError", "(",...
// MulticastQueueSchedulerLoop starts an infinit loop calling the multicast // scheduler loop.
[ "MulticastQueueSchedulerLoop", "starts", "an", "infinit", "loop", "calling", "the", "multicast", "scheduler", "loop", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/downlink/scheduler.go#L29-L37
164,116
brocaar/loraserver
internal/maccommand/new_channel.go
RequestNewChannels
func RequestNewChannels(devEUI lorawan.EUI64, maxChannels int, currentChannels, wantedChannels map[int]band.Channel) *storage.MACCommandBlock { var out []lorawan.MACCommand // sort by channel index var wantedChannelNumbers []int for i := range wantedChannels { wantedChannelNumbers = append(wantedChannelNumbers, ...
go
func RequestNewChannels(devEUI lorawan.EUI64, maxChannels int, currentChannels, wantedChannels map[int]band.Channel) *storage.MACCommandBlock { var out []lorawan.MACCommand // sort by channel index var wantedChannelNumbers []int for i := range wantedChannels { wantedChannelNumbers = append(wantedChannelNumbers, ...
[ "func", "RequestNewChannels", "(", "devEUI", "lorawan", ".", "EUI64", ",", "maxChannels", "int", ",", "currentChannels", ",", "wantedChannels", "map", "[", "int", "]", "band", ".", "Channel", ")", "*", "storage", ".", "MACCommandBlock", "{", "var", "out", "[...
// RequestNewChannels creates or modifies the non-common bi-directional // channels in case of changes between the current and wanted channels. // To avoid generating mac-command blocks which can't be sent, and to // modify the channels in multiple batches, the max number of channels to // modify must be given. In case...
[ "RequestNewChannels", "creates", "or", "modifies", "the", "non", "-", "common", "bi", "-", "directional", "channels", "in", "case", "of", "changes", "between", "the", "current", "and", "wanted", "channels", ".", "To", "avoid", "generating", "mac", "-", "comman...
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/maccommand/new_channel.go#L20-L58
164,117
brocaar/loraserver
internal/storage/storage.go
Setup
func Setup(c config.Config) error { log.Info("storage: setting up storage module") deviceSessionTTL = c.NetworkServer.DeviceSessionTTL schedulerInterval = c.NetworkServer.Scheduler.SchedulerInterval log.Info("storage: setting up Redis connection pool") redisPool = &redis.Pool{ MaxIdle: 10, IdleTimeout: c...
go
func Setup(c config.Config) error { log.Info("storage: setting up storage module") deviceSessionTTL = c.NetworkServer.DeviceSessionTTL schedulerInterval = c.NetworkServer.Scheduler.SchedulerInterval log.Info("storage: setting up Redis connection pool") redisPool = &redis.Pool{ MaxIdle: 10, IdleTimeout: c...
[ "func", "Setup", "(", "c", "config", ".", "Config", ")", "error", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n\n", "deviceSessionTTL", "=", "c", ".", "NetworkServer", ".", "DeviceSessionTTL", "\n", "schedulerInterval", "=", "c", ".", "NetworkServer",...
// Setup configures the storage backend.
[ "Setup", "configures", "the", "storage", "backend", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/storage.go#L25-L89
164,118
brocaar/loraserver
internal/storage/storage.go
Transaction
func Transaction(f func(tx sqlx.Ext) error) error { tx, err := db.Beginx() if err != nil { return errors.Wrap(err, "storage: begin transaction error") } err = f(tx) if err != nil { if rbErr := tx.Rollback(); rbErr != nil { return errors.Wrap(rbErr, "storage: transaction rollback error") } return err }...
go
func Transaction(f func(tx sqlx.Ext) error) error { tx, err := db.Beginx() if err != nil { return errors.Wrap(err, "storage: begin transaction error") } err = f(tx) if err != nil { if rbErr := tx.Rollback(); rbErr != nil { return errors.Wrap(rbErr, "storage: transaction rollback error") } return err }...
[ "func", "Transaction", "(", "f", "func", "(", "tx", "sqlx", ".", "Ext", ")", "error", ")", "error", "{", "tx", ",", "err", ":=", "db", ".", "Beginx", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",...
// Transaction wraps the given function in a transaction. In case the given // functions returns an error, the transaction will be rolled back.
[ "Transaction", "wraps", "the", "given", "function", "in", "a", "transaction", ".", "In", "case", "the", "given", "functions", "returns", "an", "error", "the", "transaction", "will", "be", "rolled", "back", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/storage/storage.go#L93-L111
164,119
brocaar/loraserver
internal/downlink/join/join.go
Setup
func Setup(conf config.Config) error { nsConfig := conf.NetworkServer.NetworkSettings rxWindow = nsConfig.RXWindow downlinkTXPower = nsConfig.DownlinkTXPower return nil }
go
func Setup(conf config.Config) error { nsConfig := conf.NetworkServer.NetworkSettings rxWindow = nsConfig.RXWindow downlinkTXPower = nsConfig.DownlinkTXPower return nil }
[ "func", "Setup", "(", "conf", "config", ".", "Config", ")", "error", "{", "nsConfig", ":=", "conf", ".", "NetworkServer", ".", "NetworkSettings", "\n", "rxWindow", "=", "nsConfig", ".", "RXWindow", "\n", "downlinkTXPower", "=", "nsConfig", ".", "DownlinkTXPowe...
// Setup sets up the join handler.
[ "Setup", "sets", "up", "the", "join", "handler", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/downlink/join/join.go#L49-L55
164,120
brocaar/loraserver
internal/downlink/join/join.go
Handle
func Handle(ds storage.DeviceSession, rxPacket models.RXPacket, phy lorawan.PHYPayload) error { ctx := joinContext{ DeviceSession: ds, PHYPayload: phy, RXPacket: rxPacket, } for _, t := range tasks { if err := t(&ctx); err != nil { return err } } return nil }
go
func Handle(ds storage.DeviceSession, rxPacket models.RXPacket, phy lorawan.PHYPayload) error { ctx := joinContext{ DeviceSession: ds, PHYPayload: phy, RXPacket: rxPacket, } for _, t := range tasks { if err := t(&ctx); err != nil { return err } } return nil }
[ "func", "Handle", "(", "ds", "storage", ".", "DeviceSession", ",", "rxPacket", "models", ".", "RXPacket", ",", "phy", "lorawan", ".", "PHYPayload", ")", "error", "{", "ctx", ":=", "joinContext", "{", "DeviceSession", ":", "ds", ",", "PHYPayload", ":", "phy...
// Handle handles a downlink join-response.
[ "Handle", "handles", "a", "downlink", "join", "-", "response", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/downlink/join/join.go#L58-L72
164,121
brocaar/loraserver
internal/backend/gateway/marshaler/gateway_config.go
MarshalGatewayConfiguration
func MarshalGatewayConfiguration(t Type, gc gw.GatewayConfiguration) ([]byte, error) { var b []byte var err error switch t { case Protobuf: b, err = proto.Marshal(&gc) case JSON: var str string m := &jsonpb.Marshaler{ EmitDefaults: true, } str, err = m.MarshalToString(&gc) b = []byte(str) } retu...
go
func MarshalGatewayConfiguration(t Type, gc gw.GatewayConfiguration) ([]byte, error) { var b []byte var err error switch t { case Protobuf: b, err = proto.Marshal(&gc) case JSON: var str string m := &jsonpb.Marshaler{ EmitDefaults: true, } str, err = m.MarshalToString(&gc) b = []byte(str) } retu...
[ "func", "MarshalGatewayConfiguration", "(", "t", "Type", ",", "gc", "gw", ".", "GatewayConfiguration", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "b", "[", "]", "byte", "\n", "var", "err", "error", "\n\n", "switch", "t", "{", "case", ...
// MarshalGatewayConfiguration marshals the GatewayConfiguration.
[ "MarshalGatewayConfiguration", "marshals", "the", "GatewayConfiguration", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/backend/gateway/marshaler/gateway_config.go#L10-L27
164,122
brocaar/loraserver
internal/backend/gateway/mqtt/backend.go
SendTXPacket
func (b *Backend) SendTXPacket(txPacket gw.DownlinkFrame) error { if txPacket.TxInfo == nil { return errors.New("tx_info must not be nil") } gatewayID := helpers.GetGatewayID(txPacket.TxInfo) return b.publishCommand(gatewayID, "down", &txPacket) }
go
func (b *Backend) SendTXPacket(txPacket gw.DownlinkFrame) error { if txPacket.TxInfo == nil { return errors.New("tx_info must not be nil") } gatewayID := helpers.GetGatewayID(txPacket.TxInfo) return b.publishCommand(gatewayID, "down", &txPacket) }
[ "func", "(", "b", "*", "Backend", ")", "SendTXPacket", "(", "txPacket", "gw", ".", "DownlinkFrame", ")", "error", "{", "if", "txPacket", ".", "TxInfo", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "gatewa...
// SendTXPacket sends the given downlink-frame to the gateway.
[ "SendTXPacket", "sends", "the", "given", "downlink", "-", "frame", "to", "the", "gateway", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/backend/gateway/mqtt/backend.go#L149-L157
164,123
brocaar/loraserver
internal/backend/gateway/mqtt/backend.go
SendGatewayConfigPacket
func (b *Backend) SendGatewayConfigPacket(configPacket gw.GatewayConfiguration) error { gatewayID := helpers.GetGatewayID(&configPacket) return b.publishCommand(gatewayID, "config", &configPacket) }
go
func (b *Backend) SendGatewayConfigPacket(configPacket gw.GatewayConfiguration) error { gatewayID := helpers.GetGatewayID(&configPacket) return b.publishCommand(gatewayID, "config", &configPacket) }
[ "func", "(", "b", "*", "Backend", ")", "SendGatewayConfigPacket", "(", "configPacket", "gw", ".", "GatewayConfiguration", ")", "error", "{", "gatewayID", ":=", "helpers", ".", "GetGatewayID", "(", "&", "configPacket", ")", "\n\n", "return", "b", ".", "publishC...
// SendGatewayConfigPacket sends the given GatewayConfigPacket to the gateway.
[ "SendGatewayConfigPacket", "sends", "the", "given", "GatewayConfigPacket", "to", "the", "gateway", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/backend/gateway/mqtt/backend.go#L160-L164
164,124
brocaar/loraserver
internal/helpers/helpers.go
SetDownlinkTXInfoDataRate
func SetDownlinkTXInfoDataRate(txInfo *gw.DownlinkTXInfo, dr int, b band.Band) error { dataRate, err := b.GetDataRate(dr) if err != nil { return errors.Wrap(err, "get data-rate error") } switch dataRate.Modulation { case band.LoRaModulation: txInfo.Modulation = common.Modulation_LORA txInfo.ModulationInfo =...
go
func SetDownlinkTXInfoDataRate(txInfo *gw.DownlinkTXInfo, dr int, b band.Band) error { dataRate, err := b.GetDataRate(dr) if err != nil { return errors.Wrap(err, "get data-rate error") } switch dataRate.Modulation { case band.LoRaModulation: txInfo.Modulation = common.Modulation_LORA txInfo.ModulationInfo =...
[ "func", "SetDownlinkTXInfoDataRate", "(", "txInfo", "*", "gw", ".", "DownlinkTXInfo", ",", "dr", "int", ",", "b", "band", ".", "Band", ")", "error", "{", "dataRate", ",", "err", ":=", "b", ".", "GetDataRate", "(", "dr", ")", "\n", "if", "err", "!=", ...
// SetDownlinkTXInfoDataRate sets the DownlinkTXInfo data-rate.
[ "SetDownlinkTXInfoDataRate", "sets", "the", "DownlinkTXInfo", "data", "-", "rate", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/helpers/helpers.go#L29-L59
164,125
brocaar/loraserver
internal/helpers/helpers.go
GetGatewayID
func GetGatewayID(v GatewayIDGetter) lorawan.EUI64 { var gatewayID lorawan.EUI64 copy(gatewayID[:], v.GetGatewayId()) return gatewayID }
go
func GetGatewayID(v GatewayIDGetter) lorawan.EUI64 { var gatewayID lorawan.EUI64 copy(gatewayID[:], v.GetGatewayId()) return gatewayID }
[ "func", "GetGatewayID", "(", "v", "GatewayIDGetter", ")", "lorawan", ".", "EUI64", "{", "var", "gatewayID", "lorawan", ".", "EUI64", "\n", "copy", "(", "gatewayID", "[", ":", "]", ",", "v", ".", "GetGatewayId", "(", ")", ")", "\n", "return", "gatewayID",...
// GetGatewayID returns the typed gateway ID.
[ "GetGatewayID", "returns", "the", "typed", "gateway", "ID", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/helpers/helpers.go#L95-L99
164,126
brocaar/loraserver
internal/helpers/helpers.go
GetDataRateIndex
func GetDataRateIndex(uplink bool, v DataRateGetter, b band.Band) (int, error) { var dr band.DataRate switch v.GetModulation() { case common.Modulation_LORA: modInfo := v.GetLoraModulationInfo() if modInfo == nil { return 0, errors.New("lora_modulation_info must not be nil") } dr.Modulation = band.LoRaMo...
go
func GetDataRateIndex(uplink bool, v DataRateGetter, b band.Band) (int, error) { var dr band.DataRate switch v.GetModulation() { case common.Modulation_LORA: modInfo := v.GetLoraModulationInfo() if modInfo == nil { return 0, errors.New("lora_modulation_info must not be nil") } dr.Modulation = band.LoRaMo...
[ "func", "GetDataRateIndex", "(", "uplink", "bool", ",", "v", "DataRateGetter", ",", "b", "band", ".", "Band", ")", "(", "int", ",", "error", ")", "{", "var", "dr", "band", ".", "DataRate", "\n\n", "switch", "v", ".", "GetModulation", "(", ")", "{", "...
// GetDataRateIndex returns the data-rate index.
[ "GetDataRateIndex", "returns", "the", "data", "-", "rate", "index", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/helpers/helpers.go#L102-L127
164,127
brocaar/loraserver
internal/backend/gateway/gcppubsub/gcppubsub.go
Close
func (b *Backend) Close() error { log.Info("gateway/gcp_pub_sub: closing backend") b.cancel() close(b.uplinkFrameChan) close(b.gatewayStatsChan) close(b.downlinkTXAckChan) return b.client.Close() }
go
func (b *Backend) Close() error { log.Info("gateway/gcp_pub_sub: closing backend") b.cancel() close(b.uplinkFrameChan) close(b.gatewayStatsChan) close(b.downlinkTXAckChan) return b.client.Close() }
[ "func", "(", "b", "*", "Backend", ")", "Close", "(", ")", "error", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n", "b", ".", "cancel", "(", ")", "\n", "close", "(", "b", ".", "uplinkFrameChan", ")", "\n", "close", "(", "b", ".", "gatewaySt...
// Close closes the backend.
[ "Close", "closes", "the", "backend", "." ]
33ed6586ede637a540864142fcda0b7e3b90203d
https://github.com/brocaar/loraserver/blob/33ed6586ede637a540864142fcda0b7e3b90203d/internal/backend/gateway/gcppubsub/gcppubsub.go#L171-L178
164,128
hashicorp/memberlist
awareness.go
ApplyDelta
func (a *awareness) ApplyDelta(delta int) { a.Lock() initial := a.score a.score += delta if a.score < 0 { a.score = 0 } else if a.score > (a.max - 1) { a.score = (a.max - 1) } final := a.score a.Unlock() if initial != final { metrics.SetGauge([]string{"memberlist", "health", "score"}, float32(final)) }...
go
func (a *awareness) ApplyDelta(delta int) { a.Lock() initial := a.score a.score += delta if a.score < 0 { a.score = 0 } else if a.score > (a.max - 1) { a.score = (a.max - 1) } final := a.score a.Unlock() if initial != final { metrics.SetGauge([]string{"memberlist", "health", "score"}, float32(final)) }...
[ "func", "(", "a", "*", "awareness", ")", "ApplyDelta", "(", "delta", "int", ")", "{", "a", ".", "Lock", "(", ")", "\n", "initial", ":=", "a", ".", "score", "\n", "a", ".", "score", "+=", "delta", "\n", "if", "a", ".", "score", "<", "0", "{", ...
// ApplyDelta takes the given delta and applies it to the score in a thread-safe // manner. It also enforces a floor of zero and a max of max, so deltas may not // change the overall score if it's railed at one of the extremes.
[ "ApplyDelta", "takes", "the", "given", "delta", "and", "applies", "it", "to", "the", "score", "in", "a", "thread", "-", "safe", "manner", ".", "It", "also", "enforces", "a", "floor", "of", "zero", "and", "a", "max", "of", "max", "so", "deltas", "may", ...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/awareness.go#L37-L52
164,129
hashicorp/memberlist
awareness.go
GetHealthScore
func (a *awareness) GetHealthScore() int { a.RLock() score := a.score a.RUnlock() return score }
go
func (a *awareness) GetHealthScore() int { a.RLock() score := a.score a.RUnlock() return score }
[ "func", "(", "a", "*", "awareness", ")", "GetHealthScore", "(", ")", "int", "{", "a", ".", "RLock", "(", ")", "\n", "score", ":=", "a", ".", "score", "\n", "a", ".", "RUnlock", "(", ")", "\n", "return", "score", "\n", "}" ]
// GetHealthScore returns the raw health score.
[ "GetHealthScore", "returns", "the", "raw", "health", "score", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/awareness.go#L55-L60
164,130
hashicorp/memberlist
awareness.go
ScaleTimeout
func (a *awareness) ScaleTimeout(timeout time.Duration) time.Duration { a.RLock() score := a.score a.RUnlock() return timeout * (time.Duration(score) + 1) }
go
func (a *awareness) ScaleTimeout(timeout time.Duration) time.Duration { a.RLock() score := a.score a.RUnlock() return timeout * (time.Duration(score) + 1) }
[ "func", "(", "a", "*", "awareness", ")", "ScaleTimeout", "(", "timeout", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "a", ".", "RLock", "(", ")", "\n", "score", ":=", "a", ".", "score", "\n", "a", ".", "RUnlock", "(", ")", "\n", "...
// ScaleTimeout takes the given duration and scales it based on the current // score. Less healthyness will lead to longer timeouts.
[ "ScaleTimeout", "takes", "the", "given", "duration", "and", "scales", "it", "based", "on", "the", "current", "score", ".", "Less", "healthyness", "will", "lead", "to", "longer", "timeouts", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/awareness.go#L64-L69
164,131
hashicorp/memberlist
keyring.go
ValidateKey
func ValidateKey(key []byte) error { if l := len(key); l != 16 && l != 24 && l != 32 { return fmt.Errorf("key size must be 16, 24 or 32 bytes") } return nil }
go
func ValidateKey(key []byte) error { if l := len(key); l != 16 && l != 24 && l != 32 { return fmt.Errorf("key size must be 16, 24 or 32 bytes") } return nil }
[ "func", "ValidateKey", "(", "key", "[", "]", "byte", ")", "error", "{", "if", "l", ":=", "len", "(", "key", ")", ";", "l", "!=", "16", "&&", "l", "!=", "24", "&&", "l", "!=", "32", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", ...
// ValidateKey will check to see if the key is valid and returns an error if not. // // key should be either 16, 24, or 32 bytes to select AES-128, // AES-192, or AES-256.
[ "ValidateKey", "will", "check", "to", "see", "if", "the", "key", "is", "valid", "and", "returns", "an", "error", "if", "not", ".", "key", "should", "be", "either", "16", "24", "or", "32", "bytes", "to", "select", "AES", "-", "128", "AES", "-", "192",...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/keyring.go#L65-L70
164,132
hashicorp/memberlist
keyring.go
AddKey
func (k *Keyring) AddKey(key []byte) error { if err := ValidateKey(key); err != nil { return err } // No-op if key is already installed for _, installedKey := range k.keys { if bytes.Equal(installedKey, key) { return nil } } keys := append(k.keys, key) primaryKey := k.GetPrimaryKey() if primaryKey ==...
go
func (k *Keyring) AddKey(key []byte) error { if err := ValidateKey(key); err != nil { return err } // No-op if key is already installed for _, installedKey := range k.keys { if bytes.Equal(installedKey, key) { return nil } } keys := append(k.keys, key) primaryKey := k.GetPrimaryKey() if primaryKey ==...
[ "func", "(", "k", "*", "Keyring", ")", "AddKey", "(", "key", "[", "]", "byte", ")", "error", "{", "if", "err", ":=", "ValidateKey", "(", "key", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// No-op if key is already installed...
// AddKey will install a new key on the ring. Adding a key to the ring will make // it available for use in decryption. If the key already exists on the ring, // this function will just return noop. // // key should be either 16, 24, or 32 bytes to select AES-128, // AES-192, or AES-256.
[ "AddKey", "will", "install", "a", "new", "key", "on", "the", "ring", ".", "Adding", "a", "key", "to", "the", "ring", "will", "make", "it", "available", "for", "use", "in", "decryption", ".", "If", "the", "key", "already", "exists", "on", "the", "ring",...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/keyring.go#L78-L97
164,133
hashicorp/memberlist
keyring.go
UseKey
func (k *Keyring) UseKey(key []byte) error { for _, installedKey := range k.keys { if bytes.Equal(key, installedKey) { k.installKeys(k.keys, key) return nil } } return fmt.Errorf("Requested key is not in the keyring") }
go
func (k *Keyring) UseKey(key []byte) error { for _, installedKey := range k.keys { if bytes.Equal(key, installedKey) { k.installKeys(k.keys, key) return nil } } return fmt.Errorf("Requested key is not in the keyring") }
[ "func", "(", "k", "*", "Keyring", ")", "UseKey", "(", "key", "[", "]", "byte", ")", "error", "{", "for", "_", ",", "installedKey", ":=", "range", "k", ".", "keys", "{", "if", "bytes", ".", "Equal", "(", "key", ",", "installedKey", ")", "{", "k", ...
// UseKey changes the key used to encrypt messages. This is the only key used to // encrypt messages, so peers should know this key before this method is called.
[ "UseKey", "changes", "the", "key", "used", "to", "encrypt", "messages", ".", "This", "is", "the", "only", "key", "used", "to", "encrypt", "messages", "so", "peers", "should", "know", "this", "key", "before", "this", "method", "is", "called", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/keyring.go#L101-L109
164,134
hashicorp/memberlist
keyring.go
installKeys
func (k *Keyring) installKeys(keys [][]byte, primaryKey []byte) { k.l.Lock() defer k.l.Unlock() newKeys := [][]byte{primaryKey} for _, key := range keys { if !bytes.Equal(key, primaryKey) { newKeys = append(newKeys, key) } } k.keys = newKeys }
go
func (k *Keyring) installKeys(keys [][]byte, primaryKey []byte) { k.l.Lock() defer k.l.Unlock() newKeys := [][]byte{primaryKey} for _, key := range keys { if !bytes.Equal(key, primaryKey) { newKeys = append(newKeys, key) } } k.keys = newKeys }
[ "func", "(", "k", "*", "Keyring", ")", "installKeys", "(", "keys", "[", "]", "[", "]", "byte", ",", "primaryKey", "[", "]", "byte", ")", "{", "k", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "k", ".", "l", ".", "Unlock", "(", ")", "\n\n",...
// installKeys will take out a lock on the keyring, and replace the keys with a // new set of keys. The key indicated by primaryKey will be installed as the new // primary key.
[ "installKeys", "will", "take", "out", "a", "lock", "on", "the", "keyring", "and", "replace", "the", "keys", "with", "a", "new", "set", "of", "keys", ".", "The", "key", "indicated", "by", "primaryKey", "will", "be", "installed", "as", "the", "new", "prima...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/keyring.go#L129-L140
164,135
hashicorp/memberlist
keyring.go
GetKeys
func (k *Keyring) GetKeys() [][]byte { k.l.Lock() defer k.l.Unlock() return k.keys }
go
func (k *Keyring) GetKeys() [][]byte { k.l.Lock() defer k.l.Unlock() return k.keys }
[ "func", "(", "k", "*", "Keyring", ")", "GetKeys", "(", ")", "[", "]", "[", "]", "byte", "{", "k", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "k", ".", "l", ".", "Unlock", "(", ")", "\n\n", "return", "k", ".", "keys", "\n", "}" ]
// GetKeys returns the current set of keys on the ring.
[ "GetKeys", "returns", "the", "current", "set", "of", "keys", "on", "the", "ring", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/keyring.go#L143-L148
164,136
hashicorp/memberlist
keyring.go
GetPrimaryKey
func (k *Keyring) GetPrimaryKey() (key []byte) { k.l.Lock() defer k.l.Unlock() if len(k.keys) > 0 { key = k.keys[0] } return }
go
func (k *Keyring) GetPrimaryKey() (key []byte) { k.l.Lock() defer k.l.Unlock() if len(k.keys) > 0 { key = k.keys[0] } return }
[ "func", "(", "k", "*", "Keyring", ")", "GetPrimaryKey", "(", ")", "(", "key", "[", "]", "byte", ")", "{", "k", ".", "l", ".", "Lock", "(", ")", "\n", "defer", "k", ".", "l", ".", "Unlock", "(", ")", "\n\n", "if", "len", "(", "k", ".", "keys...
// GetPrimaryKey returns the key on the ring at position 0. This is the key used // for encrypting messages, and is the first key tried for decrypting messages.
[ "GetPrimaryKey", "returns", "the", "key", "on", "the", "ring", "at", "position", "0", ".", "This", "is", "the", "key", "used", "for", "encrypting", "messages", "and", "is", "the", "first", "key", "tried", "for", "decrypting", "messages", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/keyring.go#L152-L160
164,137
hashicorp/memberlist
util.go
decode
func decode(buf []byte, out interface{}) error { r := bytes.NewReader(buf) hd := codec.MsgpackHandle{} dec := codec.NewDecoder(r, &hd) return dec.Decode(out) }
go
func decode(buf []byte, out interface{}) error { r := bytes.NewReader(buf) hd := codec.MsgpackHandle{} dec := codec.NewDecoder(r, &hd) return dec.Decode(out) }
[ "func", "decode", "(", "buf", "[", "]", "byte", ",", "out", "interface", "{", "}", ")", "error", "{", "r", ":=", "bytes", ".", "NewReader", "(", "buf", ")", "\n", "hd", ":=", "codec", ".", "MsgpackHandle", "{", "}", "\n", "dec", ":=", "codec", "....
// Decode reverses the encode operation on a byte slice input
[ "Decode", "reverses", "the", "encode", "operation", "on", "a", "byte", "slice", "input" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L37-L42
164,138
hashicorp/memberlist
util.go
encode
func encode(msgType messageType, in interface{}) (*bytes.Buffer, error) { buf := bytes.NewBuffer(nil) buf.WriteByte(uint8(msgType)) hd := codec.MsgpackHandle{} enc := codec.NewEncoder(buf, &hd) err := enc.Encode(in) return buf, err }
go
func encode(msgType messageType, in interface{}) (*bytes.Buffer, error) { buf := bytes.NewBuffer(nil) buf.WriteByte(uint8(msgType)) hd := codec.MsgpackHandle{} enc := codec.NewEncoder(buf, &hd) err := enc.Encode(in) return buf, err }
[ "func", "encode", "(", "msgType", "messageType", ",", "in", "interface", "{", "}", ")", "(", "*", "bytes", ".", "Buffer", ",", "error", ")", "{", "buf", ":=", "bytes", ".", "NewBuffer", "(", "nil", ")", "\n", "buf", ".", "WriteByte", "(", "uint8", ...
// Encode writes an encoded object to a new bytes buffer
[ "Encode", "writes", "an", "encoded", "object", "to", "a", "new", "bytes", "buffer" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L45-L52
164,139
hashicorp/memberlist
util.go
suspicionTimeout
func suspicionTimeout(suspicionMult, n int, interval time.Duration) time.Duration { nodeScale := math.Max(1.0, math.Log10(math.Max(1.0, float64(n)))) // multiply by 1000 to keep some precision because time.Duration is an int64 type timeout := time.Duration(suspicionMult) * time.Duration(nodeScale*1000) * interval / ...
go
func suspicionTimeout(suspicionMult, n int, interval time.Duration) time.Duration { nodeScale := math.Max(1.0, math.Log10(math.Max(1.0, float64(n)))) // multiply by 1000 to keep some precision because time.Duration is an int64 type timeout := time.Duration(suspicionMult) * time.Duration(nodeScale*1000) * interval / ...
[ "func", "suspicionTimeout", "(", "suspicionMult", ",", "n", "int", ",", "interval", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "nodeScale", ":=", "math", ".", "Max", "(", "1.0", ",", "math", ".", "Log10", "(", "math", ".", "Max", "(", ...
// suspicionTimeout computes the timeout that should be used when // a node is suspected
[ "suspicionTimeout", "computes", "the", "timeout", "that", "should", "be", "used", "when", "a", "node", "is", "suspected" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L64-L69
164,140
hashicorp/memberlist
util.go
retransmitLimit
func retransmitLimit(retransmitMult, n int) int { nodeScale := math.Ceil(math.Log10(float64(n + 1))) limit := retransmitMult * int(nodeScale) return limit }
go
func retransmitLimit(retransmitMult, n int) int { nodeScale := math.Ceil(math.Log10(float64(n + 1))) limit := retransmitMult * int(nodeScale) return limit }
[ "func", "retransmitLimit", "(", "retransmitMult", ",", "n", "int", ")", "int", "{", "nodeScale", ":=", "math", ".", "Ceil", "(", "math", ".", "Log10", "(", "float64", "(", "n", "+", "1", ")", ")", ")", "\n", "limit", ":=", "retransmitMult", "*", "int...
// retransmitLimit computes the limit of retransmissions
[ "retransmitLimit", "computes", "the", "limit", "of", "retransmissions" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L72-L76
164,141
hashicorp/memberlist
util.go
shuffleNodes
func shuffleNodes(nodes []*nodeState) { n := len(nodes) rand.Shuffle(n, func(i, j int) { nodes[i], nodes[j] = nodes[j], nodes[i] }) }
go
func shuffleNodes(nodes []*nodeState) { n := len(nodes) rand.Shuffle(n, func(i, j int) { nodes[i], nodes[j] = nodes[j], nodes[i] }) }
[ "func", "shuffleNodes", "(", "nodes", "[", "]", "*", "nodeState", ")", "{", "n", ":=", "len", "(", "nodes", ")", "\n", "rand", ".", "Shuffle", "(", "n", ",", "func", "(", "i", ",", "j", "int", ")", "{", "nodes", "[", "i", "]", ",", "nodes", "...
// shuffleNodes randomly shuffles the input nodes using the Fisher-Yates shuffle
[ "shuffleNodes", "randomly", "shuffles", "the", "input", "nodes", "using", "the", "Fisher", "-", "Yates", "shuffle" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L79-L84
164,142
hashicorp/memberlist
util.go
moveDeadNodes
func moveDeadNodes(nodes []*nodeState, gossipToTheDeadTime time.Duration) int { numDead := 0 n := len(nodes) for i := 0; i < n-numDead; i++ { if nodes[i].State != stateDead { continue } // Respect the gossip to the dead interval if time.Since(nodes[i].StateChange) <= gossipToTheDeadTime { continue }...
go
func moveDeadNodes(nodes []*nodeState, gossipToTheDeadTime time.Duration) int { numDead := 0 n := len(nodes) for i := 0; i < n-numDead; i++ { if nodes[i].State != stateDead { continue } // Respect the gossip to the dead interval if time.Since(nodes[i].StateChange) <= gossipToTheDeadTime { continue }...
[ "func", "moveDeadNodes", "(", "nodes", "[", "]", "*", "nodeState", ",", "gossipToTheDeadTime", "time", ".", "Duration", ")", "int", "{", "numDead", ":=", "0", "\n", "n", ":=", "len", "(", "nodes", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "n...
// moveDeadNodes moves nodes that are dead and beyond the gossip to the dead interval // to the end of the slice and returns the index of the first moved node.
[ "moveDeadNodes", "moves", "nodes", "that", "are", "dead", "and", "beyond", "the", "gossip", "to", "the", "dead", "interval", "to", "the", "end", "of", "the", "slice", "and", "returns", "the", "index", "of", "the", "first", "moved", "node", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L101-L120
164,143
hashicorp/memberlist
util.go
kRandomNodes
func kRandomNodes(k int, nodes []*nodeState, filterFn func(*nodeState) bool) []*nodeState { n := len(nodes) kNodes := make([]*nodeState, 0, k) OUTER: // Probe up to 3*n times, with large n this is not necessary // since k << n, but with small n we want search to be // exhaustive for i := 0; i < 3*n && len(kNodes)...
go
func kRandomNodes(k int, nodes []*nodeState, filterFn func(*nodeState) bool) []*nodeState { n := len(nodes) kNodes := make([]*nodeState, 0, k) OUTER: // Probe up to 3*n times, with large n this is not necessary // since k << n, but with small n we want search to be // exhaustive for i := 0; i < 3*n && len(kNodes)...
[ "func", "kRandomNodes", "(", "k", "int", ",", "nodes", "[", "]", "*", "nodeState", ",", "filterFn", "func", "(", "*", "nodeState", ")", "bool", ")", "[", "]", "*", "nodeState", "{", "n", ":=", "len", "(", "nodes", ")", "\n", "kNodes", ":=", "make",...
// kRandomNodes is used to select up to k random nodes, excluding any nodes where // the filter function returns true. It is possible that less than k nodes are // returned.
[ "kRandomNodes", "is", "used", "to", "select", "up", "to", "k", "random", "nodes", "excluding", "any", "nodes", "where", "the", "filter", "function", "returns", "true", ".", "It", "is", "possible", "that", "less", "than", "k", "nodes", "are", "returned", "....
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L125-L153
164,144
hashicorp/memberlist
util.go
decodeCompoundMessage
func decodeCompoundMessage(buf []byte) (trunc int, parts [][]byte, err error) { if len(buf) < 1 { err = fmt.Errorf("missing compound length byte") return } numParts := uint8(buf[0]) buf = buf[1:] // Check we have enough bytes if len(buf) < int(numParts*2) { err = fmt.Errorf("truncated len slice") return ...
go
func decodeCompoundMessage(buf []byte) (trunc int, parts [][]byte, err error) { if len(buf) < 1 { err = fmt.Errorf("missing compound length byte") return } numParts := uint8(buf[0]) buf = buf[1:] // Check we have enough bytes if len(buf) < int(numParts*2) { err = fmt.Errorf("truncated len slice") return ...
[ "func", "decodeCompoundMessage", "(", "buf", "[", "]", "byte", ")", "(", "trunc", "int", ",", "parts", "[", "]", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "buf", ")", "<", "1", "{", "err", "=", "fmt", ".", "Errorf", "("...
// decodeCompoundMessage splits a compound message and returns // the slices of individual messages. Also returns the number // of truncated messages and any potential error
[ "decodeCompoundMessage", "splits", "a", "compound", "message", "and", "returns", "the", "slices", "of", "individual", "messages", ".", "Also", "returns", "the", "number", "of", "truncated", "messages", "and", "any", "potential", "error" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L183-L217
164,145
hashicorp/memberlist
util.go
decompressBuffer
func decompressBuffer(c *compress) ([]byte, error) { // Verify the algorithm if c.Algo != lzwAlgo { return nil, fmt.Errorf("Cannot decompress unknown algorithm %d", c.Algo) } // Create a uncompressor uncomp := lzw.NewReader(bytes.NewReader(c.Buf), lzw.LSB, lzwLitWidth) defer uncomp.Close() // Read all the da...
go
func decompressBuffer(c *compress) ([]byte, error) { // Verify the algorithm if c.Algo != lzwAlgo { return nil, fmt.Errorf("Cannot decompress unknown algorithm %d", c.Algo) } // Create a uncompressor uncomp := lzw.NewReader(bytes.NewReader(c.Buf), lzw.LSB, lzwLitWidth) defer uncomp.Close() // Read all the da...
[ "func", "decompressBuffer", "(", "c", "*", "compress", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Verify the algorithm", "if", "c", ".", "Algo", "!=", "lzwAlgo", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c",...
// decompressBuffer is used to decompress the buffer of // a single compress message, handling multiple algorithms
[ "decompressBuffer", "is", "used", "to", "decompress", "the", "buffer", "of", "a", "single", "compress", "message", "handling", "multiple", "algorithms" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L256-L275
164,146
hashicorp/memberlist
util.go
ensurePort
func ensurePort(s string, port int) string { if hasPort(s) { return s } // If this is an IPv6 address, the join call will add another set of // brackets, so we have to trim before we add the default port. s = strings.Trim(s, "[]") s = net.JoinHostPort(s, strconv.Itoa(port)) return s }
go
func ensurePort(s string, port int) string { if hasPort(s) { return s } // If this is an IPv6 address, the join call will add another set of // brackets, so we have to trim before we add the default port. s = strings.Trim(s, "[]") s = net.JoinHostPort(s, strconv.Itoa(port)) return s }
[ "func", "ensurePort", "(", "s", "string", ",", "port", "int", ")", "string", "{", "if", "hasPort", "(", "s", ")", "{", "return", "s", "\n", "}", "\n\n", "// If this is an IPv6 address, the join call will add another set of", "// brackets, so we have to trim before we ad...
// ensurePort makes sure the given string has a port number on it, otherwise it // appends the given port as a default.
[ "ensurePort", "makes", "sure", "the", "given", "string", "has", "a", "port", "number", "on", "it", "otherwise", "it", "appends", "the", "given", "port", "as", "a", "default", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/util.go#L299-L309
164,147
hashicorp/memberlist
net_transport.go
NewNetTransport
func NewNetTransport(config *NetTransportConfig) (*NetTransport, error) { // If we reject the empty list outright we can assume that there's at // least one listener of each type later during operation. if len(config.BindAddrs) == 0 { return nil, fmt.Errorf("At least one bind address is required") } // Build ou...
go
func NewNetTransport(config *NetTransportConfig) (*NetTransport, error) { // If we reject the empty list outright we can assume that there's at // least one listener of each type later during operation. if len(config.BindAddrs) == 0 { return nil, fmt.Errorf("At least one bind address is required") } // Build ou...
[ "func", "NewNetTransport", "(", "config", "*", "NetTransportConfig", ")", "(", "*", "NetTransport", ",", "error", ")", "{", "// If we reject the empty list outright we can assume that there's at", "// least one listener of each type later during operation.", "if", "len", "(", "...
// NewNetTransport returns a net transport with the given configuration. On // success all the network listeners will be created and listening.
[ "NewNetTransport", "returns", "a", "net", "transport", "with", "the", "given", "configuration", ".", "On", "success", "all", "the", "network", "listeners", "will", "be", "created", "and", "listening", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net_transport.go#L53-L115
164,148
hashicorp/memberlist
net_transport.go
GetAutoBindPort
func (t *NetTransport) GetAutoBindPort() int { // We made sure there's at least one TCP listener, and that one's // port was applied to all the others for the dynamic bind case. return t.tcpListeners[0].Addr().(*net.TCPAddr).Port }
go
func (t *NetTransport) GetAutoBindPort() int { // We made sure there's at least one TCP listener, and that one's // port was applied to all the others for the dynamic bind case. return t.tcpListeners[0].Addr().(*net.TCPAddr).Port }
[ "func", "(", "t", "*", "NetTransport", ")", "GetAutoBindPort", "(", ")", "int", "{", "// We made sure there's at least one TCP listener, and that one's", "// port was applied to all the others for the dynamic bind case.", "return", "t", ".", "tcpListeners", "[", "0", "]", "."...
// GetAutoBindPort returns the bind port that was automatically given by the // kernel, if a bind port of 0 was given.
[ "GetAutoBindPort", "returns", "the", "bind", "port", "that", "was", "automatically", "given", "by", "the", "kernel", "if", "a", "bind", "port", "of", "0", "was", "given", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net_transport.go#L119-L123
164,149
hashicorp/memberlist
net_transport.go
tcpListen
func (t *NetTransport) tcpListen(tcpLn *net.TCPListener) { defer t.wg.Done() // baseDelay is the initial delay after an AcceptTCP() error before attempting again const baseDelay = 5 * time.Millisecond // maxDelay is the maximum delay after an AcceptTCP() error before attempting again. // In the case that tcpList...
go
func (t *NetTransport) tcpListen(tcpLn *net.TCPListener) { defer t.wg.Done() // baseDelay is the initial delay after an AcceptTCP() error before attempting again const baseDelay = 5 * time.Millisecond // maxDelay is the maximum delay after an AcceptTCP() error before attempting again. // In the case that tcpList...
[ "func", "(", "t", "*", "NetTransport", ")", "tcpListen", "(", "tcpLn", "*", "net", ".", "TCPListener", ")", "{", "defer", "t", ".", "wg", ".", "Done", "(", ")", "\n\n", "// baseDelay is the initial delay after an AcceptTCP() error before attempting again", "const", ...
// tcpListen is a long running goroutine that accepts incoming TCP connections // and hands them off to the stream channel.
[ "tcpListen", "is", "a", "long", "running", "goroutine", "that", "accepts", "incoming", "TCP", "connections", "and", "hands", "them", "off", "to", "the", "stream", "channel", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net_transport.go#L222-L260
164,150
hashicorp/memberlist
net_transport.go
udpListen
func (t *NetTransport) udpListen(udpLn *net.UDPConn) { defer t.wg.Done() for { // Do a blocking read into a fresh buffer. Grab a time stamp as // close as possible to the I/O. buf := make([]byte, udpPacketBufSize) n, addr, err := udpLn.ReadFrom(buf) ts := time.Now() if err != nil { if s := atomic.LoadI...
go
func (t *NetTransport) udpListen(udpLn *net.UDPConn) { defer t.wg.Done() for { // Do a blocking read into a fresh buffer. Grab a time stamp as // close as possible to the I/O. buf := make([]byte, udpPacketBufSize) n, addr, err := udpLn.ReadFrom(buf) ts := time.Now() if err != nil { if s := atomic.LoadI...
[ "func", "(", "t", "*", "NetTransport", ")", "udpListen", "(", "udpLn", "*", "net", ".", "UDPConn", ")", "{", "defer", "t", ".", "wg", ".", "Done", "(", ")", "\n", "for", "{", "// Do a blocking read into a fresh buffer. Grab a time stamp as", "// close as possibl...
// udpListen is a long running goroutine that accepts incoming UDP packets and // hands them off to the packet channel.
[ "udpListen", "is", "a", "long", "running", "goroutine", "that", "accepts", "incoming", "UDP", "packets", "and", "hands", "them", "off", "to", "the", "packet", "channel", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net_transport.go#L264-L297
164,151
hashicorp/memberlist
net_transport.go
setUDPRecvBuf
func setUDPRecvBuf(c *net.UDPConn) error { size := udpRecvBufSize var err error for size > 0 { if err = c.SetReadBuffer(size); err == nil { return nil } size = size / 2 } return err }
go
func setUDPRecvBuf(c *net.UDPConn) error { size := udpRecvBufSize var err error for size > 0 { if err = c.SetReadBuffer(size); err == nil { return nil } size = size / 2 } return err }
[ "func", "setUDPRecvBuf", "(", "c", "*", "net", ".", "UDPConn", ")", "error", "{", "size", ":=", "udpRecvBufSize", "\n", "var", "err", "error", "\n", "for", "size", ">", "0", "{", "if", "err", "=", "c", ".", "SetReadBuffer", "(", "size", ")", ";", "...
// setUDPRecvBuf is used to resize the UDP receive window. The function // attempts to set the read buffer to `udpRecvBuf` but backs off until // the read buffer can be set.
[ "setUDPRecvBuf", "is", "used", "to", "resize", "the", "UDP", "receive", "window", ".", "The", "function", "attempts", "to", "set", "the", "read", "buffer", "to", "udpRecvBuf", "but", "backs", "off", "until", "the", "read", "buffer", "can", "be", "set", "."...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net_transport.go#L302-L312
164,152
hashicorp/memberlist
net.go
streamListen
func (m *Memberlist) streamListen() { for { select { case conn := <-m.transport.StreamCh(): go m.handleConn(conn) case <-m.shutdownCh: return } } }
go
func (m *Memberlist) streamListen() { for { select { case conn := <-m.transport.StreamCh(): go m.handleConn(conn) case <-m.shutdownCh: return } } }
[ "func", "(", "m", "*", "Memberlist", ")", "streamListen", "(", ")", "{", "for", "{", "select", "{", "case", "conn", ":=", "<-", "m", ".", "transport", ".", "StreamCh", "(", ")", ":", "go", "m", ".", "handleConn", "(", "conn", ")", "\n\n", "case", ...
// streamListen is a long running goroutine that pulls incoming streams from the // transport and hands them off for processing.
[ "streamListen", "is", "a", "long", "running", "goroutine", "that", "pulls", "incoming", "streams", "from", "the", "transport", "and", "hands", "them", "off", "for", "processing", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L196-L206
164,153
hashicorp/memberlist
net.go
packetListen
func (m *Memberlist) packetListen() { for { select { case packet := <-m.transport.PacketCh(): m.ingestPacket(packet.Buf, packet.From, packet.Timestamp) case <-m.shutdownCh: return } } }
go
func (m *Memberlist) packetListen() { for { select { case packet := <-m.transport.PacketCh(): m.ingestPacket(packet.Buf, packet.From, packet.Timestamp) case <-m.shutdownCh: return } } }
[ "func", "(", "m", "*", "Memberlist", ")", "packetListen", "(", ")", "{", "for", "{", "select", "{", "case", "packet", ":=", "<-", "m", ".", "transport", ".", "PacketCh", "(", ")", ":", "m", ".", "ingestPacket", "(", "packet", ".", "Buf", ",", "pack...
// packetListen is a long running goroutine that pulls packets out of the // transport and hands them off for processing.
[ "packetListen", "is", "a", "long", "running", "goroutine", "that", "pulls", "packets", "out", "of", "the", "transport", "and", "hands", "them", "off", "for", "processing", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L299-L309
164,154
hashicorp/memberlist
net.go
getNextMessage
func (m *Memberlist) getNextMessage() (msgHandoff, bool) { m.msgQueueLock.Lock() defer m.msgQueueLock.Unlock() if el := m.highPriorityMsgQueue.Back(); el != nil { m.highPriorityMsgQueue.Remove(el) msg := el.Value.(msgHandoff) return msg, true } else if el := m.lowPriorityMsgQueue.Back(); el != nil { m.lowP...
go
func (m *Memberlist) getNextMessage() (msgHandoff, bool) { m.msgQueueLock.Lock() defer m.msgQueueLock.Unlock() if el := m.highPriorityMsgQueue.Back(); el != nil { m.highPriorityMsgQueue.Remove(el) msg := el.Value.(msgHandoff) return msg, true } else if el := m.lowPriorityMsgQueue.Back(); el != nil { m.lowP...
[ "func", "(", "m", "*", "Memberlist", ")", "getNextMessage", "(", ")", "(", "msgHandoff", ",", "bool", ")", "{", "m", ".", "msgQueueLock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "msgQueueLock", ".", "Unlock", "(", ")", "\n\n", "if", "el", "...
// getNextMessage returns the next message to process in priority order, using LIFO
[ "getNextMessage", "returns", "the", "next", "message", "to", "process", "in", "priority", "order", "using", "LIFO" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L399-L413
164,155
hashicorp/memberlist
net.go
handleUser
func (m *Memberlist) handleUser(buf []byte, from net.Addr) { d := m.config.Delegate if d != nil { d.NotifyMsg(buf) } }
go
func (m *Memberlist) handleUser(buf []byte, from net.Addr) { d := m.config.Delegate if d != nil { d.NotifyMsg(buf) } }
[ "func", "(", "m", "*", "Memberlist", ")", "handleUser", "(", "buf", "[", "]", "byte", ",", "from", "net", ".", "Addr", ")", "{", "d", ":=", "m", ".", "config", ".", "Delegate", "\n", "if", "d", "!=", "nil", "{", "d", ".", "NotifyMsg", "(", "buf...
// handleUser is used to notify channels of incoming user data
[ "handleUser", "is", "used", "to", "notify", "channels", "of", "incoming", "user", "data" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L597-L602
164,156
hashicorp/memberlist
net.go
handleCompressed
func (m *Memberlist) handleCompressed(buf []byte, from net.Addr, timestamp time.Time) { // Try to decode the payload payload, err := decompressPayload(buf) if err != nil { m.logger.Printf("[ERR] memberlist: Failed to decompress payload: %v %s", err, LogAddress(from)) return } // Recursively handle the payload...
go
func (m *Memberlist) handleCompressed(buf []byte, from net.Addr, timestamp time.Time) { // Try to decode the payload payload, err := decompressPayload(buf) if err != nil { m.logger.Printf("[ERR] memberlist: Failed to decompress payload: %v %s", err, LogAddress(from)) return } // Recursively handle the payload...
[ "func", "(", "m", "*", "Memberlist", ")", "handleCompressed", "(", "buf", "[", "]", "byte", ",", "from", "net", ".", "Addr", ",", "timestamp", "time", ".", "Time", ")", "{", "// Try to decode the payload", "payload", ",", "err", ":=", "decompressPayload", ...
// handleCompressed is used to unpack a compressed message
[ "handleCompressed", "is", "used", "to", "unpack", "a", "compressed", "message" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L605-L615
164,157
hashicorp/memberlist
net.go
encodeAndSendMsg
func (m *Memberlist) encodeAndSendMsg(addr string, msgType messageType, msg interface{}) error { out, err := encode(msgType, msg) if err != nil { return err } if err := m.sendMsg(addr, out.Bytes()); err != nil { return err } return nil }
go
func (m *Memberlist) encodeAndSendMsg(addr string, msgType messageType, msg interface{}) error { out, err := encode(msgType, msg) if err != nil { return err } if err := m.sendMsg(addr, out.Bytes()); err != nil { return err } return nil }
[ "func", "(", "m", "*", "Memberlist", ")", "encodeAndSendMsg", "(", "addr", "string", ",", "msgType", "messageType", ",", "msg", "interface", "{", "}", ")", "error", "{", "out", ",", "err", ":=", "encode", "(", "msgType", ",", "msg", ")", "\n", "if", ...
// encodeAndSendMsg is used to combine the encoding and sending steps
[ "encodeAndSendMsg", "is", "used", "to", "combine", "the", "encoding", "and", "sending", "steps" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L618-L627
164,158
hashicorp/memberlist
net.go
sendMsg
func (m *Memberlist) sendMsg(addr string, msg []byte) error { // Check if we can piggy back any messages bytesAvail := m.config.UDPBufferSize - len(msg) - compoundHeaderOverhead if m.config.EncryptionEnabled() && m.config.GossipVerifyOutgoing { bytesAvail -= encryptOverhead(m.encryptionVersion()) } extra := m.ge...
go
func (m *Memberlist) sendMsg(addr string, msg []byte) error { // Check if we can piggy back any messages bytesAvail := m.config.UDPBufferSize - len(msg) - compoundHeaderOverhead if m.config.EncryptionEnabled() && m.config.GossipVerifyOutgoing { bytesAvail -= encryptOverhead(m.encryptionVersion()) } extra := m.ge...
[ "func", "(", "m", "*", "Memberlist", ")", "sendMsg", "(", "addr", "string", ",", "msg", "[", "]", "byte", ")", "error", "{", "// Check if we can piggy back any messages", "bytesAvail", ":=", "m", ".", "config", ".", "UDPBufferSize", "-", "len", "(", "msg", ...
// sendMsg is used to send a message via packet to another host. It will // opportunistically create a compoundMsg and piggy back other broadcasts.
[ "sendMsg", "is", "used", "to", "send", "a", "message", "via", "packet", "to", "another", "host", ".", "It", "will", "opportunistically", "create", "a", "compoundMsg", "and", "piggy", "back", "other", "broadcasts", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L631-L654
164,159
hashicorp/memberlist
net.go
rawSendMsgPacket
func (m *Memberlist) rawSendMsgPacket(addr string, node *Node, msg []byte) error { // Check if we have compression enabled if m.config.EnableCompression { buf, err := compressPayload(msg) if err != nil { m.logger.Printf("[WARN] memberlist: Failed to compress payload: %v", err) } else { // Only use compres...
go
func (m *Memberlist) rawSendMsgPacket(addr string, node *Node, msg []byte) error { // Check if we have compression enabled if m.config.EnableCompression { buf, err := compressPayload(msg) if err != nil { m.logger.Printf("[WARN] memberlist: Failed to compress payload: %v", err) } else { // Only use compres...
[ "func", "(", "m", "*", "Memberlist", ")", "rawSendMsgPacket", "(", "addr", "string", ",", "node", "*", "Node", ",", "msg", "[", "]", "byte", ")", "error", "{", "// Check if we have compression enabled", "if", "m", ".", "config", ".", "EnableCompression", "{"...
// rawSendMsgPacket is used to send message via packet to another host without // modification, other than compression or encryption if enabled.
[ "rawSendMsgPacket", "is", "used", "to", "send", "message", "via", "packet", "to", "another", "host", "without", "modification", "other", "than", "compression", "or", "encryption", "if", "enabled", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L658-L713
164,160
hashicorp/memberlist
net.go
rawSendMsgStream
func (m *Memberlist) rawSendMsgStream(conn net.Conn, sendBuf []byte) error { // Check if compresion is enabled if m.config.EnableCompression { compBuf, err := compressPayload(sendBuf) if err != nil { m.logger.Printf("[ERROR] memberlist: Failed to compress payload: %v", err) } else { sendBuf = compBuf.Byte...
go
func (m *Memberlist) rawSendMsgStream(conn net.Conn, sendBuf []byte) error { // Check if compresion is enabled if m.config.EnableCompression { compBuf, err := compressPayload(sendBuf) if err != nil { m.logger.Printf("[ERROR] memberlist: Failed to compress payload: %v", err) } else { sendBuf = compBuf.Byte...
[ "func", "(", "m", "*", "Memberlist", ")", "rawSendMsgStream", "(", "conn", "net", ".", "Conn", ",", "sendBuf", "[", "]", "byte", ")", "error", "{", "// Check if compresion is enabled", "if", "m", ".", "config", ".", "EnableCompression", "{", "compBuf", ",", ...
// rawSendMsgStream is used to stream a message to another host without // modification, other than applying compression and encryption if enabled.
[ "rawSendMsgStream", "is", "used", "to", "stream", "a", "message", "to", "another", "host", "without", "modification", "other", "than", "applying", "compression", "and", "encryption", "if", "enabled", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L717-L748
164,161
hashicorp/memberlist
net.go
sendUserMsg
func (m *Memberlist) sendUserMsg(addr string, sendBuf []byte) error { conn, err := m.transport.DialTimeout(addr, m.config.TCPTimeout) if err != nil { return err } defer conn.Close() bufConn := bytes.NewBuffer(nil) if err := bufConn.WriteByte(byte(userMsg)); err != nil { return err } header := userMsgHeade...
go
func (m *Memberlist) sendUserMsg(addr string, sendBuf []byte) error { conn, err := m.transport.DialTimeout(addr, m.config.TCPTimeout) if err != nil { return err } defer conn.Close() bufConn := bytes.NewBuffer(nil) if err := bufConn.WriteByte(byte(userMsg)); err != nil { return err } header := userMsgHeade...
[ "func", "(", "m", "*", "Memberlist", ")", "sendUserMsg", "(", "addr", "string", ",", "sendBuf", "[", "]", "byte", ")", "error", "{", "conn", ",", "err", ":=", "m", ".", "transport", ".", "DialTimeout", "(", "addr", ",", "m", ".", "config", ".", "TC...
// sendUserMsg is used to stream a user message to another host.
[ "sendUserMsg", "is", "used", "to", "stream", "a", "user", "message", "to", "another", "host", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L751-L773
164,162
hashicorp/memberlist
net.go
sendLocalState
func (m *Memberlist) sendLocalState(conn net.Conn, join bool) error { // Setup a deadline conn.SetDeadline(time.Now().Add(m.config.TCPTimeout)) // Prepare the local node state m.nodeLock.RLock() localNodes := make([]pushNodeState, len(m.nodes)) for idx, n := range m.nodes { localNodes[idx].Name = n.Name loca...
go
func (m *Memberlist) sendLocalState(conn net.Conn, join bool) error { // Setup a deadline conn.SetDeadline(time.Now().Add(m.config.TCPTimeout)) // Prepare the local node state m.nodeLock.RLock() localNodes := make([]pushNodeState, len(m.nodes)) for idx, n := range m.nodes { localNodes[idx].Name = n.Name loca...
[ "func", "(", "m", "*", "Memberlist", ")", "sendLocalState", "(", "conn", "net", ".", "Conn", ",", "join", "bool", ")", "error", "{", "// Setup a deadline", "conn", ".", "SetDeadline", "(", "time", ".", "Now", "(", ")", ".", "Add", "(", "m", ".", "con...
// sendLocalState is invoked to send our local state over a stream connection.
[ "sendLocalState", "is", "invoked", "to", "send", "our", "local", "state", "over", "a", "stream", "connection", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L818-L876
164,163
hashicorp/memberlist
net.go
encryptLocalState
func (m *Memberlist) encryptLocalState(sendBuf []byte) ([]byte, error) { var buf bytes.Buffer // Write the encryptMsg byte buf.WriteByte(byte(encryptMsg)) // Write the size of the message sizeBuf := make([]byte, 4) encVsn := m.encryptionVersion() encLen := encryptedLength(encVsn, len(sendBuf)) binary.BigEndia...
go
func (m *Memberlist) encryptLocalState(sendBuf []byte) ([]byte, error) { var buf bytes.Buffer // Write the encryptMsg byte buf.WriteByte(byte(encryptMsg)) // Write the size of the message sizeBuf := make([]byte, 4) encVsn := m.encryptionVersion() encLen := encryptedLength(encVsn, len(sendBuf)) binary.BigEndia...
[ "func", "(", "m", "*", "Memberlist", ")", "encryptLocalState", "(", "sendBuf", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "// Write the encryptMsg byte", "buf", ".", "WriteByte", "(...
// encryptLocalState is used to help encrypt local state before sending
[ "encryptLocalState", "is", "used", "to", "help", "encrypt", "local", "state", "before", "sending" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L879-L899
164,164
hashicorp/memberlist
net.go
decryptRemoteState
func (m *Memberlist) decryptRemoteState(bufConn io.Reader) ([]byte, error) { // Read in enough to determine message length cipherText := bytes.NewBuffer(nil) cipherText.WriteByte(byte(encryptMsg)) _, err := io.CopyN(cipherText, bufConn, 4) if err != nil { return nil, err } // Ensure we aren't asked to downloa...
go
func (m *Memberlist) decryptRemoteState(bufConn io.Reader) ([]byte, error) { // Read in enough to determine message length cipherText := bytes.NewBuffer(nil) cipherText.WriteByte(byte(encryptMsg)) _, err := io.CopyN(cipherText, bufConn, 4) if err != nil { return nil, err } // Ensure we aren't asked to downloa...
[ "func", "(", "m", "*", "Memberlist", ")", "decryptRemoteState", "(", "bufConn", "io", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Read in enough to determine message length", "cipherText", ":=", "bytes", ".", "NewBuffer", "(", "nil",...
// decryptRemoteState is used to help decrypt the remote state
[ "decryptRemoteState", "is", "used", "to", "help", "decrypt", "the", "remote", "state" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L902-L931
164,165
hashicorp/memberlist
net.go
readStream
func (m *Memberlist) readStream(conn net.Conn) (messageType, io.Reader, *codec.Decoder, error) { // Created a buffered reader var bufConn io.Reader = bufio.NewReader(conn) // Read the message type buf := [1]byte{0} if _, err := bufConn.Read(buf[:]); err != nil { return 0, nil, nil, err } msgType := messageTyp...
go
func (m *Memberlist) readStream(conn net.Conn) (messageType, io.Reader, *codec.Decoder, error) { // Created a buffered reader var bufConn io.Reader = bufio.NewReader(conn) // Read the message type buf := [1]byte{0} if _, err := bufConn.Read(buf[:]); err != nil { return 0, nil, nil, err } msgType := messageTyp...
[ "func", "(", "m", "*", "Memberlist", ")", "readStream", "(", "conn", "net", ".", "Conn", ")", "(", "messageType", ",", "io", ".", "Reader", ",", "*", "codec", ".", "Decoder", ",", "error", ")", "{", "// Created a buffered reader", "var", "bufConn", "io",...
// readStream is used to read from a stream connection, decrypting and // decompressing the stream if necessary.
[ "readStream", "is", "used", "to", "read", "from", "a", "stream", "connection", "decrypting", "and", "decompressing", "the", "stream", "if", "necessary", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L935-L992
164,166
hashicorp/memberlist
net.go
readRemoteState
func (m *Memberlist) readRemoteState(bufConn io.Reader, dec *codec.Decoder) (bool, []pushNodeState, []byte, error) { // Read the push/pull header var header pushPullHeader if err := dec.Decode(&header); err != nil { return false, nil, nil, err } // Allocate space for the transfer remoteNodes := make([]pushNode...
go
func (m *Memberlist) readRemoteState(bufConn io.Reader, dec *codec.Decoder) (bool, []pushNodeState, []byte, error) { // Read the push/pull header var header pushPullHeader if err := dec.Decode(&header); err != nil { return false, nil, nil, err } // Allocate space for the transfer remoteNodes := make([]pushNode...
[ "func", "(", "m", "*", "Memberlist", ")", "readRemoteState", "(", "bufConn", "io", ".", "Reader", ",", "dec", "*", "codec", ".", "Decoder", ")", "(", "bool", ",", "[", "]", "pushNodeState", ",", "[", "]", "byte", ",", "error", ")", "{", "// Read the ...
// readRemoteState is used to read the remote state from a connection
[ "readRemoteState", "is", "used", "to", "read", "the", "remote", "state", "from", "a", "connection" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L995-L1036
164,167
hashicorp/memberlist
net.go
mergeRemoteState
func (m *Memberlist) mergeRemoteState(join bool, remoteNodes []pushNodeState, userBuf []byte) error { if err := m.verifyProtocol(remoteNodes); err != nil { return err } // Invoke the merge delegate if any if join && m.config.Merge != nil { nodes := make([]*Node, len(remoteNodes)) for idx, n := range remoteNo...
go
func (m *Memberlist) mergeRemoteState(join bool, remoteNodes []pushNodeState, userBuf []byte) error { if err := m.verifyProtocol(remoteNodes); err != nil { return err } // Invoke the merge delegate if any if join && m.config.Merge != nil { nodes := make([]*Node, len(remoteNodes)) for idx, n := range remoteNo...
[ "func", "(", "m", "*", "Memberlist", ")", "mergeRemoteState", "(", "join", "bool", ",", "remoteNodes", "[", "]", "pushNodeState", ",", "userBuf", "[", "]", "byte", ")", "error", "{", "if", "err", ":=", "m", ".", "verifyProtocol", "(", "remoteNodes", ")",...
// mergeRemoteState is used to merge the remote state with our local state
[ "mergeRemoteState", "is", "used", "to", "merge", "the", "remote", "state", "with", "our", "local", "state" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L1039-L1074
164,168
hashicorp/memberlist
net.go
readUserMsg
func (m *Memberlist) readUserMsg(bufConn io.Reader, dec *codec.Decoder) error { // Read the user message header var header userMsgHeader if err := dec.Decode(&header); err != nil { return err } // Read the user message into a buffer var userBuf []byte if header.UserMsgLen > 0 { userBuf = make([]byte, header...
go
func (m *Memberlist) readUserMsg(bufConn io.Reader, dec *codec.Decoder) error { // Read the user message header var header userMsgHeader if err := dec.Decode(&header); err != nil { return err } // Read the user message into a buffer var userBuf []byte if header.UserMsgLen > 0 { userBuf = make([]byte, header...
[ "func", "(", "m", "*", "Memberlist", ")", "readUserMsg", "(", "bufConn", "io", ".", "Reader", ",", "dec", "*", "codec", ".", "Decoder", ")", "error", "{", "// Read the user message header", "var", "header", "userMsgHeader", "\n", "if", "err", ":=", "dec", ...
// readUserMsg is used to decode a userMsg from a stream.
[ "readUserMsg", "is", "used", "to", "decode", "a", "userMsg", "from", "a", "stream", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L1077-L1105
164,169
hashicorp/memberlist
net.go
sendPingAndWaitForAck
func (m *Memberlist) sendPingAndWaitForAck(addr string, ping ping, deadline time.Time) (bool, error) { conn, err := m.transport.DialTimeout(addr, deadline.Sub(time.Now())) if err != nil { // If the node is actually dead we expect this to fail, so we // shouldn't spam the logs with it. After this point, errors /...
go
func (m *Memberlist) sendPingAndWaitForAck(addr string, ping ping, deadline time.Time) (bool, error) { conn, err := m.transport.DialTimeout(addr, deadline.Sub(time.Now())) if err != nil { // If the node is actually dead we expect this to fail, so we // shouldn't spam the logs with it. After this point, errors /...
[ "func", "(", "m", "*", "Memberlist", ")", "sendPingAndWaitForAck", "(", "addr", "string", ",", "ping", "ping", ",", "deadline", "time", ".", "Time", ")", "(", "bool", ",", "error", ")", "{", "conn", ",", "err", ":=", "m", ".", "transport", ".", "Dial...
// sendPingAndWaitForAck makes a stream connection to the given address, sends // a ping, and waits for an ack. All of this is done as a series of blocking // operations, given the deadline. The bool return parameter is true if we // we able to round trip a ping to the other node.
[ "sendPingAndWaitForAck", "makes", "a", "stream", "connection", "to", "the", "given", "address", "sends", "a", "ping", "and", "waits", "for", "an", "ack", ".", "All", "of", "this", "is", "done", "as", "a", "series", "of", "blocking", "operations", "given", ...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/net.go#L1111-L1151
164,170
hashicorp/memberlist
security.go
pkcs7encode
func pkcs7encode(buf *bytes.Buffer, ignore, blockSize int) { n := buf.Len() - ignore more := blockSize - (n % blockSize) for i := 0; i < more; i++ { buf.WriteByte(byte(more)) } }
go
func pkcs7encode(buf *bytes.Buffer, ignore, blockSize int) { n := buf.Len() - ignore more := blockSize - (n % blockSize) for i := 0; i < more; i++ { buf.WriteByte(byte(more)) } }
[ "func", "pkcs7encode", "(", "buf", "*", "bytes", ".", "Buffer", ",", "ignore", ",", "blockSize", "int", ")", "{", "n", ":=", "buf", ".", "Len", "(", ")", "-", "ignore", "\n", "more", ":=", "blockSize", "-", "(", "n", "%", "blockSize", ")", "\n", ...
// pkcs7encode is used to pad a byte buffer to a specific block size using // the PKCS7 algorithm. "Ignores" some bytes to compensate for IV
[ "pkcs7encode", "is", "used", "to", "pad", "a", "byte", "buffer", "to", "a", "specific", "block", "size", "using", "the", "PKCS7", "algorithm", ".", "Ignores", "some", "bytes", "to", "compensate", "for", "IV" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/security.go#L39-L45
164,171
hashicorp/memberlist
security.go
pkcs7decode
func pkcs7decode(buf []byte, blockSize int) []byte { if len(buf) == 0 { panic("Cannot decode a PKCS7 buffer of zero length") } n := len(buf) last := buf[n-1] n -= int(last) return buf[:n] }
go
func pkcs7decode(buf []byte, blockSize int) []byte { if len(buf) == 0 { panic("Cannot decode a PKCS7 buffer of zero length") } n := len(buf) last := buf[n-1] n -= int(last) return buf[:n] }
[ "func", "pkcs7decode", "(", "buf", "[", "]", "byte", ",", "blockSize", "int", ")", "[", "]", "byte", "{", "if", "len", "(", "buf", ")", "==", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "n", ":=", "len", "(", "buf", ")", "\n", ...
// pkcs7decode is used to decode a buffer that has been padded
[ "pkcs7decode", "is", "used", "to", "decode", "a", "buffer", "that", "has", "been", "padded" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/security.go#L48-L56
164,172
hashicorp/memberlist
security.go
encryptedLength
func encryptedLength(vsn encryptionVersion, inp int) int { // If we are on version 1, there is no padding if vsn >= 1 { return versionSize + nonceSize + inp + tagSize } // Determine the padding size padding := blockSize - (inp % blockSize) // Sum the extra parts to get total size return versionSize + nonceSi...
go
func encryptedLength(vsn encryptionVersion, inp int) int { // If we are on version 1, there is no padding if vsn >= 1 { return versionSize + nonceSize + inp + tagSize } // Determine the padding size padding := blockSize - (inp % blockSize) // Sum the extra parts to get total size return versionSize + nonceSi...
[ "func", "encryptedLength", "(", "vsn", "encryptionVersion", ",", "inp", "int", ")", "int", "{", "// If we are on version 1, there is no padding", "if", "vsn", ">=", "1", "{", "return", "versionSize", "+", "nonceSize", "+", "inp", "+", "tagSize", "\n", "}", "\n\n...
// encryptedLength is used to compute the buffer size needed // for a message of given length
[ "encryptedLength", "is", "used", "to", "compute", "the", "buffer", "size", "needed", "for", "a", "message", "of", "given", "length" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/security.go#L72-L83
164,173
hashicorp/memberlist
security.go
encryptPayload
func encryptPayload(vsn encryptionVersion, key []byte, msg []byte, data []byte, dst *bytes.Buffer) error { // Get the AES block cipher aesBlock, err := aes.NewCipher(key) if err != nil { return err } // Get the GCM cipher mode gcm, err := cipher.NewGCM(aesBlock) if err != nil { return err } // Grow the b...
go
func encryptPayload(vsn encryptionVersion, key []byte, msg []byte, data []byte, dst *bytes.Buffer) error { // Get the AES block cipher aesBlock, err := aes.NewCipher(key) if err != nil { return err } // Get the GCM cipher mode gcm, err := cipher.NewGCM(aesBlock) if err != nil { return err } // Grow the b...
[ "func", "encryptPayload", "(", "vsn", "encryptionVersion", ",", "key", "[", "]", "byte", ",", "msg", "[", "]", "byte", ",", "data", "[", "]", "byte", ",", "dst", "*", "bytes", ".", "Buffer", ")", "error", "{", "// Get the AES block cipher", "aesBlock", "...
// encryptPayload is used to encrypt a message with a given key. // We make use of AES-128 in GCM mode. New byte buffer is the version, // nonce, ciphertext and tag
[ "encryptPayload", "is", "used", "to", "encrypt", "a", "message", "with", "a", "given", "key", ".", "We", "make", "use", "of", "AES", "-", "128", "in", "GCM", "mode", ".", "New", "byte", "buffer", "is", "the", "version", "nonce", "ciphertext", "and", "t...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/security.go#L88-L136
164,174
hashicorp/memberlist
security.go
decryptMessage
func decryptMessage(key, msg []byte, data []byte) ([]byte, error) { // Get the AES block cipher aesBlock, err := aes.NewCipher(key) if err != nil { return nil, err } // Get the GCM cipher mode gcm, err := cipher.NewGCM(aesBlock) if err != nil { return nil, err } // Decrypt the message nonce := msg[versi...
go
func decryptMessage(key, msg []byte, data []byte) ([]byte, error) { // Get the AES block cipher aesBlock, err := aes.NewCipher(key) if err != nil { return nil, err } // Get the GCM cipher mode gcm, err := cipher.NewGCM(aesBlock) if err != nil { return nil, err } // Decrypt the message nonce := msg[versi...
[ "func", "decryptMessage", "(", "key", ",", "msg", "[", "]", "byte", ",", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Get the AES block cipher", "aesBlock", ",", "err", ":=", "aes", ".", "NewCipher", "(", "key", "...
// decryptMessage performs the actual decryption of ciphertext. This is in its // own function to allow it to be called on all keys easily.
[ "decryptMessage", "performs", "the", "actual", "decryption", "of", "ciphertext", ".", "This", "is", "in", "its", "own", "function", "to", "allow", "it", "to", "be", "called", "on", "all", "keys", "easily", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/security.go#L140-L163
164,175
hashicorp/memberlist
security.go
decryptPayload
func decryptPayload(keys [][]byte, msg []byte, data []byte) ([]byte, error) { // Ensure we have at least one byte if len(msg) == 0 { return nil, fmt.Errorf("Cannot decrypt empty payload") } // Verify the version vsn := encryptionVersion(msg[0]) if vsn > maxEncryptionVersion { return nil, fmt.Errorf("Unsuppor...
go
func decryptPayload(keys [][]byte, msg []byte, data []byte) ([]byte, error) { // Ensure we have at least one byte if len(msg) == 0 { return nil, fmt.Errorf("Cannot decrypt empty payload") } // Verify the version vsn := encryptionVersion(msg[0]) if vsn > maxEncryptionVersion { return nil, fmt.Errorf("Unsuppor...
[ "func", "decryptPayload", "(", "keys", "[", "]", "[", "]", "byte", ",", "msg", "[", "]", "byte", ",", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Ensure we have at least one byte", "if", "len", "(", "msg", ")", ...
// decryptPayload is used to decrypt a message with a given key, // and verify it's contents. Any padding will be removed, and a // slice to the plaintext is returned. Decryption is done IN PLACE!
[ "decryptPayload", "is", "used", "to", "decrypt", "a", "message", "with", "a", "given", "key", "and", "verify", "it", "s", "contents", ".", "Any", "padding", "will", "be", "removed", "and", "a", "slice", "to", "the", "plaintext", "is", "returned", ".", "D...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/security.go#L168-L198
164,176
hashicorp/memberlist
state.go
schedule
func (m *Memberlist) schedule() { m.tickerLock.Lock() defer m.tickerLock.Unlock() // If we already have tickers, then don't do anything, since we're // scheduled if len(m.tickers) > 0 { return } // Create the stop tick channel, a blocking channel. We close this // when we should stop the tickers. stopCh :=...
go
func (m *Memberlist) schedule() { m.tickerLock.Lock() defer m.tickerLock.Unlock() // If we already have tickers, then don't do anything, since we're // scheduled if len(m.tickers) > 0 { return } // Create the stop tick channel, a blocking channel. We close this // when we should stop the tickers. stopCh :=...
[ "func", "(", "m", "*", "Memberlist", ")", "schedule", "(", ")", "{", "m", ".", "tickerLock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "tickerLock", ".", "Unlock", "(", ")", "\n\n", "// If we already have tickers, then don't do anything, since we're", "/...
// Schedule is used to ensure the Tick is performed periodically. This // function is safe to call multiple times. If the memberlist is already // scheduled, then it won't do anything.
[ "Schedule", "is", "used", "to", "ensure", "the", "Tick", "is", "performed", "periodically", ".", "This", "function", "is", "safe", "to", "call", "multiple", "times", ".", "If", "the", "memberlist", "is", "already", "scheduled", "then", "it", "won", "t", "d...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L82-L120
164,177
hashicorp/memberlist
state.go
triggerFunc
func (m *Memberlist) triggerFunc(stagger time.Duration, C <-chan time.Time, stop <-chan struct{}, f func()) { // Use a random stagger to avoid syncronizing randStagger := time.Duration(uint64(rand.Int63()) % uint64(stagger)) select { case <-time.After(randStagger): case <-stop: return } for { select { case...
go
func (m *Memberlist) triggerFunc(stagger time.Duration, C <-chan time.Time, stop <-chan struct{}, f func()) { // Use a random stagger to avoid syncronizing randStagger := time.Duration(uint64(rand.Int63()) % uint64(stagger)) select { case <-time.After(randStagger): case <-stop: return } for { select { case...
[ "func", "(", "m", "*", "Memberlist", ")", "triggerFunc", "(", "stagger", "time", ".", "Duration", ",", "C", "<-", "chan", "time", ".", "Time", ",", "stop", "<-", "chan", "struct", "{", "}", ",", "f", "func", "(", ")", ")", "{", "// Use a random stagg...
// triggerFunc is used to trigger a function call each time a // message is received until a stop tick arrives.
[ "triggerFunc", "is", "used", "to", "trigger", "a", "function", "call", "each", "time", "a", "message", "is", "received", "until", "a", "stop", "tick", "arrives", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L124-L140
164,178
hashicorp/memberlist
state.go
deschedule
func (m *Memberlist) deschedule() { m.tickerLock.Lock() defer m.tickerLock.Unlock() // If we have no tickers, then we aren't scheduled. if len(m.tickers) == 0 { return } // Close the stop channel so all the ticker listeners stop. close(m.stopTick) // Explicitly stop all the tickers themselves so they don't...
go
func (m *Memberlist) deschedule() { m.tickerLock.Lock() defer m.tickerLock.Unlock() // If we have no tickers, then we aren't scheduled. if len(m.tickers) == 0 { return } // Close the stop channel so all the ticker listeners stop. close(m.stopTick) // Explicitly stop all the tickers themselves so they don't...
[ "func", "(", "m", "*", "Memberlist", ")", "deschedule", "(", ")", "{", "m", ".", "tickerLock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "tickerLock", ".", "Unlock", "(", ")", "\n\n", "// If we have no tickers, then we aren't scheduled.", "if", "len", ...
// Deschedule is used to stop the background maintenance. This is safe // to call multiple times.
[ "Deschedule", "is", "used", "to", "stop", "the", "background", "maintenance", ".", "This", "is", "safe", "to", "call", "multiple", "times", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L171-L189
164,179
hashicorp/memberlist
state.go
probe
func (m *Memberlist) probe() { // Track the number of indexes we've considered probing numCheck := 0 START: m.nodeLock.RLock() // Make sure we don't wrap around infinitely if numCheck >= len(m.nodes) { m.nodeLock.RUnlock() return } // Handle the wrap around case if m.probeIndex >= len(m.nodes) { m.nodeL...
go
func (m *Memberlist) probe() { // Track the number of indexes we've considered probing numCheck := 0 START: m.nodeLock.RLock() // Make sure we don't wrap around infinitely if numCheck >= len(m.nodes) { m.nodeLock.RUnlock() return } // Handle the wrap around case if m.probeIndex >= len(m.nodes) { m.nodeL...
[ "func", "(", "m", "*", "Memberlist", ")", "probe", "(", ")", "{", "// Track the number of indexes we've considered probing", "numCheck", ":=", "0", "\n", "START", ":", "m", ".", "nodeLock", ".", "RLock", "(", ")", "\n\n", "// Make sure we don't wrap around infinitel...
// Tick is used to perform a single round of failure detection and gossip
[ "Tick", "is", "used", "to", "perform", "a", "single", "round", "of", "failure", "detection", "and", "gossip" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L192-L234
164,180
hashicorp/memberlist
state.go
Ping
func (m *Memberlist) Ping(node string, addr net.Addr) (time.Duration, error) { // Prepare a ping message and setup an ack handler. ping := ping{SeqNo: m.nextSeqNo(), Node: node} ackCh := make(chan ackMessage, m.config.IndirectChecks+1) m.setProbeChannels(ping.SeqNo, ackCh, nil, m.config.ProbeInterval) // Send a p...
go
func (m *Memberlist) Ping(node string, addr net.Addr) (time.Duration, error) { // Prepare a ping message and setup an ack handler. ping := ping{SeqNo: m.nextSeqNo(), Node: node} ackCh := make(chan ackMessage, m.config.IndirectChecks+1) m.setProbeChannels(ping.SeqNo, ackCh, nil, m.config.ProbeInterval) // Send a p...
[ "func", "(", "m", "*", "Memberlist", ")", "Ping", "(", "node", "string", ",", "addr", "net", ".", "Addr", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "// Prepare a ping message and setup an ack handler.", "ping", ":=", "ping", "{", "SeqNo", ...
// Ping initiates a ping to the node with the specified name.
[ "Ping", "initiates", "a", "ping", "to", "the", "node", "with", "the", "specified", "name", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L432-L460
164,181
hashicorp/memberlist
state.go
resetNodes
func (m *Memberlist) resetNodes() { m.nodeLock.Lock() defer m.nodeLock.Unlock() // Move dead nodes, but respect gossip to the dead interval deadIdx := moveDeadNodes(m.nodes, m.config.GossipToTheDeadTime) // Deregister the dead nodes for i := deadIdx; i < len(m.nodes); i++ { delete(m.nodeMap, m.nodes[i].Name) ...
go
func (m *Memberlist) resetNodes() { m.nodeLock.Lock() defer m.nodeLock.Unlock() // Move dead nodes, but respect gossip to the dead interval deadIdx := moveDeadNodes(m.nodes, m.config.GossipToTheDeadTime) // Deregister the dead nodes for i := deadIdx; i < len(m.nodes); i++ { delete(m.nodeMap, m.nodes[i].Name) ...
[ "func", "(", "m", "*", "Memberlist", ")", "resetNodes", "(", ")", "{", "m", ".", "nodeLock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "nodeLock", ".", "Unlock", "(", ")", "\n\n", "// Move dead nodes, but respect gossip to the dead interval", "deadIdx", ...
// resetNodes is used when the tick wraps around. It will reap the // dead nodes and shuffle the node list.
[ "resetNodes", "is", "used", "when", "the", "tick", "wraps", "around", ".", "It", "will", "reap", "the", "dead", "nodes", "and", "shuffle", "the", "node", "list", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L464-L485
164,182
hashicorp/memberlist
state.go
gossip
func (m *Memberlist) gossip() { defer metrics.MeasureSince([]string{"memberlist", "gossip"}, time.Now()) // Get some random live, suspect, or recently dead nodes m.nodeLock.RLock() kNodes := kRandomNodes(m.config.GossipNodes, m.nodes, func(n *nodeState) bool { if n.Name == m.config.Name { return true } s...
go
func (m *Memberlist) gossip() { defer metrics.MeasureSince([]string{"memberlist", "gossip"}, time.Now()) // Get some random live, suspect, or recently dead nodes m.nodeLock.RLock() kNodes := kRandomNodes(m.config.GossipNodes, m.nodes, func(n *nodeState) bool { if n.Name == m.config.Name { return true } s...
[ "func", "(", "m", "*", "Memberlist", ")", "gossip", "(", ")", "{", "defer", "metrics", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now", "(", ")", ")", "\n\n", "// Get some random live, susp...
// gossip is invoked every GossipInterval period to broadcast our gossip // messages to a few random nodes.
[ "gossip", "is", "invoked", "every", "GossipInterval", "period", "to", "broadcast", "our", "gossip", "messages", "to", "a", "few", "random", "nodes", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L489-L539
164,183
hashicorp/memberlist
state.go
pushPull
func (m *Memberlist) pushPull() { // Get a random live node m.nodeLock.RLock() nodes := kRandomNodes(1, m.nodes, func(n *nodeState) bool { return n.Name == m.config.Name || n.State != stateAlive }) m.nodeLock.RUnlock() // If no nodes, bail if len(nodes) == 0 { return } node := nodes[0] // Attempt a p...
go
func (m *Memberlist) pushPull() { // Get a random live node m.nodeLock.RLock() nodes := kRandomNodes(1, m.nodes, func(n *nodeState) bool { return n.Name == m.config.Name || n.State != stateAlive }) m.nodeLock.RUnlock() // If no nodes, bail if len(nodes) == 0 { return } node := nodes[0] // Attempt a p...
[ "func", "(", "m", "*", "Memberlist", ")", "pushPull", "(", ")", "{", "// Get a random live node", "m", ".", "nodeLock", ".", "RLock", "(", ")", "\n", "nodes", ":=", "kRandomNodes", "(", "1", ",", "m", ".", "nodes", ",", "func", "(", "n", "*", "nodeSt...
// pushPull is invoked periodically to randomly perform a complete state // exchange. Used to ensure a high level of convergence, but is also // reasonably expensive as the entire state of this node is exchanged // with the other node.
[ "pushPull", "is", "invoked", "periodically", "to", "randomly", "perform", "a", "complete", "state", "exchange", ".", "Used", "to", "ensure", "a", "high", "level", "of", "convergence", "but", "is", "also", "reasonably", "expensive", "as", "the", "entire", "stat...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L545-L564
164,184
hashicorp/memberlist
state.go
pushPullNode
func (m *Memberlist) pushPullNode(addr string, join bool) error { defer metrics.MeasureSince([]string{"memberlist", "pushPullNode"}, time.Now()) // Attempt to send and receive with the node remote, userState, err := m.sendAndReceiveState(addr, join) if err != nil { return err } if err := m.mergeRemoteState(jo...
go
func (m *Memberlist) pushPullNode(addr string, join bool) error { defer metrics.MeasureSince([]string{"memberlist", "pushPullNode"}, time.Now()) // Attempt to send and receive with the node remote, userState, err := m.sendAndReceiveState(addr, join) if err != nil { return err } if err := m.mergeRemoteState(jo...
[ "func", "(", "m", "*", "Memberlist", ")", "pushPullNode", "(", "addr", "string", ",", "join", "bool", ")", "error", "{", "defer", "metrics", ".", "MeasureSince", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", "}", ",", "time", ".", "Now...
// pushPullNode does a complete state exchange with a specific node.
[ "pushPullNode", "does", "a", "complete", "state", "exchange", "with", "a", "specific", "node", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L567-L580
164,185
hashicorp/memberlist
state.go
skipIncarnation
func (m *Memberlist) skipIncarnation(offset uint32) uint32 { return atomic.AddUint32(&m.incarnation, offset) }
go
func (m *Memberlist) skipIncarnation(offset uint32) uint32 { return atomic.AddUint32(&m.incarnation, offset) }
[ "func", "(", "m", "*", "Memberlist", ")", "skipIncarnation", "(", "offset", "uint32", ")", "uint32", "{", "return", "atomic", ".", "AddUint32", "(", "&", "m", ".", "incarnation", ",", "offset", ")", "\n", "}" ]
// skipIncarnation adds the positive offset to the incarnation number.
[ "skipIncarnation", "adds", "the", "positive", "offset", "to", "the", "incarnation", "number", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L712-L714
164,186
hashicorp/memberlist
state.go
setProbeChannels
func (m *Memberlist) setProbeChannels(seqNo uint32, ackCh chan ackMessage, nackCh chan struct{}, timeout time.Duration) { // Create handler functions for acks and nacks ackFn := func(payload []byte, timestamp time.Time) { select { case ackCh <- ackMessage{true, payload, timestamp}: default: } } nackFn := fu...
go
func (m *Memberlist) setProbeChannels(seqNo uint32, ackCh chan ackMessage, nackCh chan struct{}, timeout time.Duration) { // Create handler functions for acks and nacks ackFn := func(payload []byte, timestamp time.Time) { select { case ackCh <- ackMessage{true, payload, timestamp}: default: } } nackFn := fu...
[ "func", "(", "m", "*", "Memberlist", ")", "setProbeChannels", "(", "seqNo", "uint32", ",", "ackCh", "chan", "ackMessage", ",", "nackCh", "chan", "struct", "{", "}", ",", "timeout", "time", ".", "Duration", ")", "{", "// Create handler functions for acks and nack...
// setProbeChannels is used to attach the ackCh to receive a message when an ack // with a given sequence number is received. The `complete` field of the message // will be false on timeout. Any nack messages will cause an empty struct to be // passed to the nackCh, which can be nil if not needed.
[ "setProbeChannels", "is", "used", "to", "attach", "the", "ackCh", "to", "receive", "a", "message", "when", "an", "ack", "with", "a", "given", "sequence", "number", "is", "received", ".", "The", "complete", "field", "of", "the", "message", "will", "be", "fa...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L731-L762
164,187
hashicorp/memberlist
state.go
setAckHandler
func (m *Memberlist) setAckHandler(seqNo uint32, ackFn func([]byte, time.Time), timeout time.Duration) { // Add the handler ah := &ackHandler{ackFn, nil, nil} m.ackLock.Lock() m.ackHandlers[seqNo] = ah m.ackLock.Unlock() // Setup a reaping routing ah.timer = time.AfterFunc(timeout, func() { m.ackLock.Lock() ...
go
func (m *Memberlist) setAckHandler(seqNo uint32, ackFn func([]byte, time.Time), timeout time.Duration) { // Add the handler ah := &ackHandler{ackFn, nil, nil} m.ackLock.Lock() m.ackHandlers[seqNo] = ah m.ackLock.Unlock() // Setup a reaping routing ah.timer = time.AfterFunc(timeout, func() { m.ackLock.Lock() ...
[ "func", "(", "m", "*", "Memberlist", ")", "setAckHandler", "(", "seqNo", "uint32", ",", "ackFn", "func", "(", "[", "]", "byte", ",", "time", ".", "Time", ")", ",", "timeout", "time", ".", "Duration", ")", "{", "// Add the handler", "ah", ":=", "&", "...
// setAckHandler is used to attach a handler to be invoked when an ack with a // given sequence number is received. If a timeout is reached, the handler is // deleted. This is used for indirect pings so does not configure a function // for nacks.
[ "setAckHandler", "is", "used", "to", "attach", "a", "handler", "to", "be", "invoked", "when", "an", "ack", "with", "a", "given", "sequence", "number", "is", "received", ".", "If", "a", "timeout", "is", "reached", "the", "handler", "is", "deleted", ".", "...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L768-L781
164,188
hashicorp/memberlist
state.go
invokeAckHandler
func (m *Memberlist) invokeAckHandler(ack ackResp, timestamp time.Time) { m.ackLock.Lock() ah, ok := m.ackHandlers[ack.SeqNo] delete(m.ackHandlers, ack.SeqNo) m.ackLock.Unlock() if !ok { return } ah.timer.Stop() ah.ackFn(ack.Payload, timestamp) }
go
func (m *Memberlist) invokeAckHandler(ack ackResp, timestamp time.Time) { m.ackLock.Lock() ah, ok := m.ackHandlers[ack.SeqNo] delete(m.ackHandlers, ack.SeqNo) m.ackLock.Unlock() if !ok { return } ah.timer.Stop() ah.ackFn(ack.Payload, timestamp) }
[ "func", "(", "m", "*", "Memberlist", ")", "invokeAckHandler", "(", "ack", "ackResp", ",", "timestamp", "time", ".", "Time", ")", "{", "m", ".", "ackLock", ".", "Lock", "(", ")", "\n", "ah", ",", "ok", ":=", "m", ".", "ackHandlers", "[", "ack", ".",...
// Invokes an ack handler if any is associated, and reaps the handler immediately
[ "Invokes", "an", "ack", "handler", "if", "any", "is", "associated", "and", "reaps", "the", "handler", "immediately" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L784-L794
164,189
hashicorp/memberlist
state.go
invokeNackHandler
func (m *Memberlist) invokeNackHandler(nack nackResp) { m.ackLock.Lock() ah, ok := m.ackHandlers[nack.SeqNo] m.ackLock.Unlock() if !ok || ah.nackFn == nil { return } ah.nackFn() }
go
func (m *Memberlist) invokeNackHandler(nack nackResp) { m.ackLock.Lock() ah, ok := m.ackHandlers[nack.SeqNo] m.ackLock.Unlock() if !ok || ah.nackFn == nil { return } ah.nackFn() }
[ "func", "(", "m", "*", "Memberlist", ")", "invokeNackHandler", "(", "nack", "nackResp", ")", "{", "m", ".", "ackLock", ".", "Lock", "(", ")", "\n", "ah", ",", "ok", ":=", "m", ".", "ackHandlers", "[", "nack", ".", "SeqNo", "]", "\n", "m", ".", "a...
// Invokes nack handler if any is associated.
[ "Invokes", "nack", "handler", "if", "any", "is", "associated", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L797-L805
164,190
hashicorp/memberlist
state.go
refute
func (m *Memberlist) refute(me *nodeState, accusedInc uint32) { // Make sure the incarnation number beats the accusation. inc := m.nextIncarnation() if accusedInc >= inc { inc = m.skipIncarnation(accusedInc - inc + 1) } me.Incarnation = inc // Decrease our health because we are being asked to refute a problem....
go
func (m *Memberlist) refute(me *nodeState, accusedInc uint32) { // Make sure the incarnation number beats the accusation. inc := m.nextIncarnation() if accusedInc >= inc { inc = m.skipIncarnation(accusedInc - inc + 1) } me.Incarnation = inc // Decrease our health because we are being asked to refute a problem....
[ "func", "(", "m", "*", "Memberlist", ")", "refute", "(", "me", "*", "nodeState", ",", "accusedInc", "uint32", ")", "{", "// Make sure the incarnation number beats the accusation.", "inc", ":=", "m", ".", "nextIncarnation", "(", ")", "\n", "if", "accusedInc", ">=...
// refute gossips an alive message in response to incoming information that we // are suspect or dead. It will make sure the incarnation number beats the given // accusedInc value, or you can supply 0 to just get the next incarnation number. // This alters the node state that's passed in so this MUST be called while th...
[ "refute", "gossips", "an", "alive", "message", "in", "response", "to", "incoming", "information", "that", "we", "are", "suspect", "or", "dead", ".", "It", "will", "make", "sure", "the", "incarnation", "number", "beats", "the", "given", "accusedInc", "value", ...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L812-L836
164,191
hashicorp/memberlist
state.go
suspectNode
func (m *Memberlist) suspectNode(s *suspect) { m.nodeLock.Lock() defer m.nodeLock.Unlock() state, ok := m.nodeMap[s.Node] // If we've never heard about this node before, ignore it if !ok { return } // Ignore old incarnation numbers if s.Incarnation < state.Incarnation { return } // See if there's a sus...
go
func (m *Memberlist) suspectNode(s *suspect) { m.nodeLock.Lock() defer m.nodeLock.Unlock() state, ok := m.nodeMap[s.Node] // If we've never heard about this node before, ignore it if !ok { return } // Ignore old incarnation numbers if s.Incarnation < state.Incarnation { return } // See if there's a sus...
[ "func", "(", "m", "*", "Memberlist", ")", "suspectNode", "(", "s", "*", "suspect", ")", "{", "m", ".", "nodeLock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "nodeLock", ".", "Unlock", "(", ")", "\n", "state", ",", "ok", ":=", "m", ".", "n...
// suspectNode is invoked by the network layer when we get a message // about a suspect node
[ "suspectNode", "is", "invoked", "by", "the", "network", "layer", "when", "we", "get", "a", "message", "about", "a", "suspect", "node" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L1033-L1117
164,192
hashicorp/memberlist
state.go
deadNode
func (m *Memberlist) deadNode(d *dead) { m.nodeLock.Lock() defer m.nodeLock.Unlock() state, ok := m.nodeMap[d.Node] // If we've never heard about this node before, ignore it if !ok { return } // Ignore old incarnation numbers if d.Incarnation < state.Incarnation { return } // Clear out any suspicion ti...
go
func (m *Memberlist) deadNode(d *dead) { m.nodeLock.Lock() defer m.nodeLock.Unlock() state, ok := m.nodeMap[d.Node] // If we've never heard about this node before, ignore it if !ok { return } // Ignore old incarnation numbers if d.Incarnation < state.Incarnation { return } // Clear out any suspicion ti...
[ "func", "(", "m", "*", "Memberlist", ")", "deadNode", "(", "d", "*", "dead", ")", "{", "m", ".", "nodeLock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "nodeLock", ".", "Unlock", "(", ")", "\n", "state", ",", "ok", ":=", "m", ".", "nodeMap...
// deadNode is invoked by the network layer when we get a message // about a dead node
[ "deadNode", "is", "invoked", "by", "the", "network", "layer", "when", "we", "get", "a", "message", "about", "a", "dead", "node" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/state.go#L1121-L1171
164,193
hashicorp/memberlist
broadcast.go
encodeAndBroadcast
func (m *Memberlist) encodeAndBroadcast(node string, msgType messageType, msg interface{}) { m.encodeBroadcastNotify(node, msgType, msg, nil) }
go
func (m *Memberlist) encodeAndBroadcast(node string, msgType messageType, msg interface{}) { m.encodeBroadcastNotify(node, msgType, msg, nil) }
[ "func", "(", "m", "*", "Memberlist", ")", "encodeAndBroadcast", "(", "node", "string", ",", "msgType", "messageType", ",", "msg", "interface", "{", "}", ")", "{", "m", ".", "encodeBroadcastNotify", "(", "node", ",", "msgType", ",", "msg", ",", "nil", ")"...
// encodeAndBroadcast encodes a message and enqueues it for broadcast. Fails // silently if there is an encoding error.
[ "encodeAndBroadcast", "encodes", "a", "message", "and", "enqueues", "it", "for", "broadcast", ".", "Fails", "silently", "if", "there", "is", "an", "encoding", "error", "." ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/broadcast.go#L50-L52
164,194
hashicorp/memberlist
broadcast.go
encodeBroadcastNotify
func (m *Memberlist) encodeBroadcastNotify(node string, msgType messageType, msg interface{}, notify chan struct{}) { buf, err := encode(msgType, msg) if err != nil { m.logger.Printf("[ERR] memberlist: Failed to encode message for broadcast: %s", err) } else { m.queueBroadcast(node, buf.Bytes(), notify) } }
go
func (m *Memberlist) encodeBroadcastNotify(node string, msgType messageType, msg interface{}, notify chan struct{}) { buf, err := encode(msgType, msg) if err != nil { m.logger.Printf("[ERR] memberlist: Failed to encode message for broadcast: %s", err) } else { m.queueBroadcast(node, buf.Bytes(), notify) } }
[ "func", "(", "m", "*", "Memberlist", ")", "encodeBroadcastNotify", "(", "node", "string", ",", "msgType", "messageType", ",", "msg", "interface", "{", "}", ",", "notify", "chan", "struct", "{", "}", ")", "{", "buf", ",", "err", ":=", "encode", "(", "ms...
// encodeBroadcastNotify encodes a message and enqueues it for broadcast // and notifies the given channel when transmission is finished. Fails // silently if there is an encoding error.
[ "encodeBroadcastNotify", "encodes", "a", "message", "and", "enqueues", "it", "for", "broadcast", "and", "notifies", "the", "given", "channel", "when", "transmission", "is", "finished", ".", "Fails", "silently", "if", "there", "is", "an", "encoding", "error", "."...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/broadcast.go#L57-L64
164,195
hashicorp/memberlist
broadcast.go
queueBroadcast
func (m *Memberlist) queueBroadcast(node string, msg []byte, notify chan struct{}) { b := &memberlistBroadcast{node, msg, notify} m.broadcasts.QueueBroadcast(b) }
go
func (m *Memberlist) queueBroadcast(node string, msg []byte, notify chan struct{}) { b := &memberlistBroadcast{node, msg, notify} m.broadcasts.QueueBroadcast(b) }
[ "func", "(", "m", "*", "Memberlist", ")", "queueBroadcast", "(", "node", "string", ",", "msg", "[", "]", "byte", ",", "notify", "chan", "struct", "{", "}", ")", "{", "b", ":=", "&", "memberlistBroadcast", "{", "node", ",", "msg", ",", "notify", "}", ...
// queueBroadcast is used to start dissemination of a message. It will be // sent up to a configured number of times. The message could potentially // be invalidated by a future message about the same node
[ "queueBroadcast", "is", "used", "to", "start", "dissemination", "of", "a", "message", ".", "It", "will", "be", "sent", "up", "to", "a", "configured", "number", "of", "times", ".", "The", "message", "could", "potentially", "be", "invalidated", "by", "a", "f...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/broadcast.go#L69-L72
164,196
hashicorp/memberlist
broadcast.go
getBroadcasts
func (m *Memberlist) getBroadcasts(overhead, limit int) [][]byte { // Get memberlist messages first toSend := m.broadcasts.GetBroadcasts(overhead, limit) // Check if the user has anything to broadcast d := m.config.Delegate if d != nil { // Determine the bytes used already bytesUsed := 0 for _, msg := range...
go
func (m *Memberlist) getBroadcasts(overhead, limit int) [][]byte { // Get memberlist messages first toSend := m.broadcasts.GetBroadcasts(overhead, limit) // Check if the user has anything to broadcast d := m.config.Delegate if d != nil { // Determine the bytes used already bytesUsed := 0 for _, msg := range...
[ "func", "(", "m", "*", "Memberlist", ")", "getBroadcasts", "(", "overhead", ",", "limit", "int", ")", "[", "]", "[", "]", "byte", "{", "// Get memberlist messages first", "toSend", ":=", "m", ".", "broadcasts", ".", "GetBroadcasts", "(", "overhead", ",", "...
// getBroadcasts is used to return a slice of broadcasts to send up to // a maximum byte size, while imposing a per-broadcast overhead. This is used // to fill a UDP packet with piggybacked data
[ "getBroadcasts", "is", "used", "to", "return", "a", "slice", "of", "broadcasts", "to", "send", "up", "to", "a", "maximum", "byte", "size", "while", "imposing", "a", "per", "-", "broadcast", "overhead", ".", "This", "is", "used", "to", "fill", "a", "UDP",...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/broadcast.go#L77-L105
164,197
hashicorp/memberlist
memberlist.go
BuildVsnArray
func (conf *Config) BuildVsnArray() []uint8 { return []uint8{ ProtocolVersionMin, ProtocolVersionMax, conf.ProtocolVersion, conf.DelegateProtocolMin, conf.DelegateProtocolMax, conf.DelegateProtocolVersion, } }
go
func (conf *Config) BuildVsnArray() []uint8 { return []uint8{ ProtocolVersionMin, ProtocolVersionMax, conf.ProtocolVersion, conf.DelegateProtocolMin, conf.DelegateProtocolMax, conf.DelegateProtocolVersion, } }
[ "func", "(", "conf", "*", "Config", ")", "BuildVsnArray", "(", ")", "[", "]", "uint8", "{", "return", "[", "]", "uint8", "{", "ProtocolVersionMin", ",", "ProtocolVersionMax", ",", "conf", ".", "ProtocolVersion", ",", "conf", ".", "DelegateProtocolMin", ",", ...
// BuildVsnArray creates the array of Vsn
[ "BuildVsnArray", "creates", "the", "array", "of", "Vsn" ]
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/memberlist.go#L76-L82
164,198
hashicorp/memberlist
memberlist.go
Join
func (m *Memberlist) Join(existing []string) (int, error) { numSuccess := 0 var errs error for _, exist := range existing { addrs, err := m.resolveAddr(exist) if err != nil { err = fmt.Errorf("Failed to resolve %s: %v", exist, err) errs = multierror.Append(errs, err) m.logger.Printf("[WARN] memberlist: ...
go
func (m *Memberlist) Join(existing []string) (int, error) { numSuccess := 0 var errs error for _, exist := range existing { addrs, err := m.resolveAddr(exist) if err != nil { err = fmt.Errorf("Failed to resolve %s: %v", exist, err) errs = multierror.Append(errs, err) m.logger.Printf("[WARN] memberlist: ...
[ "func", "(", "m", "*", "Memberlist", ")", "Join", "(", "existing", "[", "]", "string", ")", "(", "int", ",", "error", ")", "{", "numSuccess", ":=", "0", "\n", "var", "errs", "error", "\n", "for", "_", ",", "exist", ":=", "range", "existing", "{", ...
// Join is used to take an existing Memberlist and attempt to join a cluster // by contacting all the given hosts and performing a state sync. Initially, // the Memberlist only contains our own state, so doing this will cause // remote nodes to become aware of the existence of this node, effectively // joining the clus...
[ "Join", "is", "used", "to", "take", "an", "existing", "Memberlist", "and", "attempt", "to", "join", "a", "cluster", "by", "contacting", "all", "the", "given", "hosts", "and", "performing", "a", "state", "sync", ".", "Initially", "the", "Memberlist", "only", ...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/memberlist.go#L228-L256
164,199
hashicorp/memberlist
memberlist.go
tcpLookupIP
func (m *Memberlist) tcpLookupIP(host string, defaultPort uint16) ([]ipPort, error) { // Don't attempt any TCP lookups against non-fully qualified domain // names, since those will likely come from the resolv.conf file. if !strings.Contains(host, ".") { return nil, nil } // Make sure the domain name is terminat...
go
func (m *Memberlist) tcpLookupIP(host string, defaultPort uint16) ([]ipPort, error) { // Don't attempt any TCP lookups against non-fully qualified domain // names, since those will likely come from the resolv.conf file. if !strings.Contains(host, ".") { return nil, nil } // Make sure the domain name is terminat...
[ "func", "(", "m", "*", "Memberlist", ")", "tcpLookupIP", "(", "host", "string", ",", "defaultPort", "uint16", ")", "(", "[", "]", "ipPort", ",", "error", ")", "{", "// Don't attempt any TCP lookups against non-fully qualified domain", "// names, since those will likely ...
// tcpLookupIP is a helper to initiate a TCP-based DNS lookup for the given host. // The built-in Go resolver will do a UDP lookup first, and will only use TCP if // the response has the truncate bit set, which isn't common on DNS servers like // Consul's. By doing the TCP lookup directly, we get the best chance for th...
[ "tcpLookupIP", "is", "a", "helper", "to", "initiate", "a", "TCP", "-", "based", "DNS", "lookup", "for", "the", "given", "host", ".", "The", "built", "-", "in", "Go", "resolver", "will", "do", "a", "UDP", "lookup", "first", "and", "will", "only", "use",...
a8f83c6403e0c718e9336784a270c09dc4613d3e
https://github.com/hashicorp/memberlist/blob/a8f83c6403e0c718e9336784a270c09dc4613d3e/memberlist.go#L270-L323