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
22,900
TheThingsNetwork/ttn
utils/random/random.go
RSSI
func (r *TTNRandom) RSSI() int32 { // Generate RSSI. Tend towards generating great signal strength. x := float64(r.Interface.Intn(math.MaxInt32)) * float64(2e-9) return int32(-1.6 * math.Exp(x)) }
go
func (r *TTNRandom) RSSI() int32 { // Generate RSSI. Tend towards generating great signal strength. x := float64(r.Interface.Intn(math.MaxInt32)) * float64(2e-9) return int32(-1.6 * math.Exp(x)) }
[ "func", "(", "r", "*", "TTNRandom", ")", "RSSI", "(", ")", "int32", "{", "// Generate RSSI. Tend towards generating great signal strength.", "x", ":=", "float64", "(", "r", ".", "Interface", ".", "Intn", "(", "math", ".", "MaxInt32", ")", ")", "*", "float64", ...
// RSSI generates RSSI signal between -120 < rssi < 0
[ "RSSI", "generates", "RSSI", "signal", "between", "-", "120", "<", "rssi", "<", "0" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/random/random.go#L74-L78
22,901
TheThingsNetwork/ttn
utils/random/random.go
Freq
func (r *TTNRandom) Freq() float32 { return freqs[r.Interface.Intn(len(freqs))] }
go
func (r *TTNRandom) Freq() float32 { return freqs[r.Interface.Intn(len(freqs))] }
[ "func", "(", "r", "*", "TTNRandom", ")", "Freq", "(", ")", "float32", "{", "return", "freqs", "[", "r", ".", "Interface", ".", "Intn", "(", "len", "(", "freqs", ")", ")", "]", "\n", "}" ]
// Freq generates a frequency between 867.1 and 905.3 Mhz
[ "Freq", "generates", "a", "frequency", "between", "867", ".", "1", "and", "905", ".", "3", "Mhz" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/random/random.go#L105-L107
22,902
TheThingsNetwork/ttn
utils/random/random.go
LSNR
func (r *TTNRandom) LSNR() float32 { x := float64(r.Interface.Intn(math.MaxInt32)) * float64(2e-9) return float32(math.Floor((-0.1*math.Exp(x)+5.5)*10) / 10) }
go
func (r *TTNRandom) LSNR() float32 { x := float64(r.Interface.Intn(math.MaxInt32)) * float64(2e-9) return float32(math.Floor((-0.1*math.Exp(x)+5.5)*10) / 10) }
[ "func", "(", "r", "*", "TTNRandom", ")", "LSNR", "(", ")", "float32", "{", "x", ":=", "float64", "(", "r", ".", "Interface", ".", "Intn", "(", "math", ".", "MaxInt32", ")", ")", "*", "float64", "(", "2e-9", ")", "\n", "return", "float32", "(", "m...
// LSNR generates LoRa SNR ratio in db. Tend towards generating good ratio with low noise
[ "LSNR", "generates", "LoRa", "SNR", "ratio", "in", "db", ".", "Tend", "towards", "generating", "good", "ratio", "with", "low", "noise" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/random/random.go#L131-L134
22,903
TheThingsNetwork/ttn
core/discovery/discovery.go
NewRedisDiscovery
func NewRedisDiscovery(client *redis.Client) Discovery { return &discovery{ services: announcement.NewRedisAnnouncementStore(client, "discovery"), masterAuthServers: make(map[string]struct{}), } }
go
func NewRedisDiscovery(client *redis.Client) Discovery { return &discovery{ services: announcement.NewRedisAnnouncementStore(client, "discovery"), masterAuthServers: make(map[string]struct{}), } }
[ "func", "NewRedisDiscovery", "(", "client", "*", "redis", ".", "Client", ")", "Discovery", "{", "return", "&", "discovery", "{", "services", ":", "announcement", ".", "NewRedisAnnouncementStore", "(", "client", ",", "\"", "\"", ")", ",", "masterAuthServers", "...
// NewRedisDiscovery creates a new Redis-based discovery service
[ "NewRedisDiscovery", "creates", "a", "new", "Redis", "-", "based", "discovery", "service" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/discovery.go#L162-L167
22,904
TheThingsNetwork/ttn
core/handler/application/store.go
NewRedisApplicationStore
func NewRedisApplicationStore(client *redis.Client, prefix string) Store { if prefix == "" { prefix = defaultRedisPrefix } store := storage.NewRedisMapStore(client, prefix+":"+redisApplicationPrefix) store.SetBase(Application{}, "") for v, f := range migrate.ApplicationMigrations(prefix) { store.AddMigration(v...
go
func NewRedisApplicationStore(client *redis.Client, prefix string) Store { if prefix == "" { prefix = defaultRedisPrefix } store := storage.NewRedisMapStore(client, prefix+":"+redisApplicationPrefix) store.SetBase(Application{}, "") for v, f := range migrate.ApplicationMigrations(prefix) { store.AddMigration(v...
[ "func", "NewRedisApplicationStore", "(", "client", "*", "redis", ".", "Client", ",", "prefix", "string", ")", "Store", "{", "if", "prefix", "==", "\"", "\"", "{", "prefix", "=", "defaultRedisPrefix", "\n", "}", "\n", "store", ":=", "storage", ".", "NewRedi...
// NewRedisApplicationStore creates a new Redis-based Application store // if an empty prefix is passed, a default prefix will be used.
[ "NewRedisApplicationStore", "creates", "a", "new", "Redis", "-", "based", "Application", "store", "if", "an", "empty", "prefix", "is", "passed", "a", "default", "prefix", "will", "be", "used", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/application/store.go#L29-L43
22,905
TheThingsNetwork/ttn
core/handler/application/store.go
Get
func (s *RedisApplicationStore) Get(appID string) (*Application, error) { applicationI, err := s.store.Get(appID) if err != nil { return nil, err } if application, ok := applicationI.(Application); ok { return &application, nil } return nil, errors.New("Database did not return a Application") }
go
func (s *RedisApplicationStore) Get(appID string) (*Application, error) { applicationI, err := s.store.Get(appID) if err != nil { return nil, err } if application, ok := applicationI.(Application); ok { return &application, nil } return nil, errors.New("Database did not return a Application") }
[ "func", "(", "s", "*", "RedisApplicationStore", ")", "Get", "(", "appID", "string", ")", "(", "*", "Application", ",", "error", ")", "{", "applicationI", ",", "err", ":=", "s", ".", "store", ".", "Get", "(", "appID", ")", "\n", "if", "err", "!=", "...
// Get a specific Application
[ "Get", "a", "specific", "Application" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/application/store.go#L72-L81
22,906
TheThingsNetwork/ttn
core/handler/application/store.go
Set
func (s *RedisApplicationStore) Set(new *Application, properties ...string) (err error) { now := time.Now() new.UpdatedAt = now if new.old == nil { new.CreatedAt = now } err = s.store.Set(new.AppID, *new, properties...) if err != nil { return } return nil }
go
func (s *RedisApplicationStore) Set(new *Application, properties ...string) (err error) { now := time.Now() new.UpdatedAt = now if new.old == nil { new.CreatedAt = now } err = s.store.Set(new.AppID, *new, properties...) if err != nil { return } return nil }
[ "func", "(", "s", "*", "RedisApplicationStore", ")", "Set", "(", "new", "*", "Application", ",", "properties", "...", "string", ")", "(", "err", "error", ")", "{", "now", ":=", "time", ".", "Now", "(", ")", "\n", "new", ".", "UpdatedAt", "=", "now", ...
// Set a new Application or update an existing one
[ "Set", "a", "new", "Application", "or", "update", "an", "existing", "one" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/application/store.go#L84-L95
22,907
TheThingsNetwork/ttn
core/handler/application/store.go
Delete
func (s *RedisApplicationStore) Delete(appID string) error { return s.store.Delete(appID) }
go
func (s *RedisApplicationStore) Delete(appID string) error { return s.store.Delete(appID) }
[ "func", "(", "s", "*", "RedisApplicationStore", ")", "Delete", "(", "appID", "string", ")", "error", "{", "return", "s", ".", "store", ".", "Delete", "(", "appID", ")", "\n", "}" ]
// Delete an Application
[ "Delete", "an", "Application" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/application/store.go#L98-L100
22,908
TheThingsNetwork/ttn
core/component/status.go
RegisterHealthServer
func (c *Component) RegisterHealthServer(srv *grpc.Server) { c.healthServer = health.NewServer() healthpb.RegisterHealthServer(srv, c.healthServer) grpc_prometheus.Register(srv) }
go
func (c *Component) RegisterHealthServer(srv *grpc.Server) { c.healthServer = health.NewServer() healthpb.RegisterHealthServer(srv, c.healthServer) grpc_prometheus.Register(srv) }
[ "func", "(", "c", "*", "Component", ")", "RegisterHealthServer", "(", "srv", "*", "grpc", ".", "Server", ")", "{", "c", ".", "healthServer", "=", "health", ".", "NewServer", "(", ")", "\n", "healthpb", ".", "RegisterHealthServer", "(", "srv", ",", "c", ...
// RegisterHealthServer registers the component's health status to the gRPC server
[ "RegisterHealthServer", "registers", "the", "component", "s", "health", "status", "to", "the", "gRPC", "server" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/status.go#L85-L89
22,909
TheThingsNetwork/ttn
core/handler/functions/logger.go
JSON
func JSON(val otto.Value) string { vm := otto.New() vm.Set("value", val) res, _ := vm.Run(`JSON.stringify(value)`) return res.String() }
go
func JSON(val otto.Value) string { vm := otto.New() vm.Set("value", val) res, _ := vm.Run(`JSON.stringify(value)`) return res.String() }
[ "func", "JSON", "(", "val", "otto", ".", "Value", ")", "string", "{", "vm", ":=", "otto", ".", "New", "(", ")", "\n", "vm", ".", "Set", "(", "\"", "\"", ",", "val", ")", "\n", "res", ",", "_", ":=", "vm", ".", "Run", "(", "`JSON.stringify(value...
// JSON stringifies a value inside of the otto vm, yielding better // results than Export for Object-like class such as Date, but being much // slower.
[ "JSON", "stringifies", "a", "value", "inside", "of", "the", "otto", "vm", "yielding", "better", "results", "than", "Export", "for", "Object", "-", "like", "class", "such", "as", "Date", "but", "being", "much", "slower", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/functions/logger.go#L39-L44
22,910
TheThingsNetwork/ttn
ttnctl/util/uplink_metadata.go
GetProtocolMetadata
func GetProtocolMetadata(dataRate string) *protocol.RxMetadata { return &protocol.RxMetadata{Protocol: &protocol.RxMetadata_LoRaWAN{LoRaWAN: &lorawan.Metadata{ CodingRate: "4/5", DataRate: dataRate, Modulation: lorawan.Modulation_LORA, }}} }
go
func GetProtocolMetadata(dataRate string) *protocol.RxMetadata { return &protocol.RxMetadata{Protocol: &protocol.RxMetadata_LoRaWAN{LoRaWAN: &lorawan.Metadata{ CodingRate: "4/5", DataRate: dataRate, Modulation: lorawan.Modulation_LORA, }}} }
[ "func", "GetProtocolMetadata", "(", "dataRate", "string", ")", "*", "protocol", ".", "RxMetadata", "{", "return", "&", "protocol", ".", "RxMetadata", "{", "Protocol", ":", "&", "protocol", ".", "RxMetadata_LoRaWAN", "{", "LoRaWAN", ":", "&", "lorawan", ".", ...
// GetProtocolMetadata returns protocol metadata for the given datarate
[ "GetProtocolMetadata", "returns", "protocol", "metadata", "for", "the", "given", "datarate" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/uplink_metadata.go#L13-L19
22,911
TheThingsNetwork/ttn
ttnctl/util/uplink_metadata.go
GetGatewayMetadata
func GetGatewayMetadata(id string, freq uint64) *gateway.RxMetadata { return &gateway.RxMetadata{ GatewayID: id, Timestamp: 0, Frequency: freq, RSSI: -25.0, SNR: 5.0, } }
go
func GetGatewayMetadata(id string, freq uint64) *gateway.RxMetadata { return &gateway.RxMetadata{ GatewayID: id, Timestamp: 0, Frequency: freq, RSSI: -25.0, SNR: 5.0, } }
[ "func", "GetGatewayMetadata", "(", "id", "string", ",", "freq", "uint64", ")", "*", "gateway", ".", "RxMetadata", "{", "return", "&", "gateway", ".", "RxMetadata", "{", "GatewayID", ":", "id", ",", "Timestamp", ":", "0", ",", "Frequency", ":", "freq", ",...
// GetGatewayMetadata returns gateway metadata for the given gateway ID and frequency
[ "GetGatewayMetadata", "returns", "gateway", "metadata", "for", "the", "given", "gateway", "ID", "and", "frequency" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/uplink_metadata.go#L22-L30
22,912
TheThingsNetwork/ttn
core/band/adr.go
ADRSettings
func (f *FrequencyPlan) ADRSettings(dataRate string, txPower int, snr float32, deviceMargin float32) (desiredDataRate string, desiredTxPower int, err error) { if f.ADR == nil { return dataRate, txPower, ErrADRUnavailable } margin := linkMargin(dataRate, snr) - deviceMargin drIdx, err := f.GetDataRateIndexFor(data...
go
func (f *FrequencyPlan) ADRSettings(dataRate string, txPower int, snr float32, deviceMargin float32) (desiredDataRate string, desiredTxPower int, err error) { if f.ADR == nil { return dataRate, txPower, ErrADRUnavailable } margin := linkMargin(dataRate, snr) - deviceMargin drIdx, err := f.GetDataRateIndexFor(data...
[ "func", "(", "f", "*", "FrequencyPlan", ")", "ADRSettings", "(", "dataRate", "string", ",", "txPower", "int", ",", "snr", "float32", ",", "deviceMargin", "float32", ")", "(", "desiredDataRate", "string", ",", "desiredTxPower", "int", ",", "err", "error", ")"...
// ADRSettings gets the ADR settings given a dataRate, txPower, SNR and device margin
[ "ADRSettings", "gets", "the", "ADR", "settings", "given", "a", "dataRate", "txPower", "SNR", "and", "device", "margin" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/band/adr.go#L39-L80
22,913
TheThingsNetwork/ttn
core/band/band.go
Guess
func Guess(frequency uint64) string { // Join frequencies switch { case frequency == 923200000 || frequency == 923400000: // not considering AS_920_923 and AS_923_925 because we're not sure return pb_lorawan.FrequencyPlan_AS_923.String() case frequency == 922100000 || frequency == 922300000 || frequency == 9225...
go
func Guess(frequency uint64) string { // Join frequencies switch { case frequency == 923200000 || frequency == 923400000: // not considering AS_920_923 and AS_923_925 because we're not sure return pb_lorawan.FrequencyPlan_AS_923.String() case frequency == 922100000 || frequency == 922300000 || frequency == 9225...
[ "func", "Guess", "(", "frequency", "uint64", ")", "string", "{", "// Join frequencies", "switch", "{", "case", "frequency", "==", "923200000", "||", "frequency", "==", "923400000", ":", "// not considering AS_920_923 and AS_923_925 because we're not sure", "return", "pb_l...
// Guess the region based on frequency
[ "Guess", "the", "region", "based", "on", "frequency" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/band/band.go#L50-L67
22,914
TheThingsNetwork/ttn
core/band/band.go
InitializeTables
func InitializeTables() { initializeOnce.Do(func() { frequencyPlans = make(map[string]FrequencyPlan) channels = make(map[int]string) for _, r := range []pb_lorawan.FrequencyPlan{ // ordering is important here pb_lorawan.FrequencyPlan_EU_863_870, pb_lorawan.FrequencyPlan_IN_865_867, pb_lorawan.FrequencyP...
go
func InitializeTables() { initializeOnce.Do(func() { frequencyPlans = make(map[string]FrequencyPlan) channels = make(map[int]string) for _, r := range []pb_lorawan.FrequencyPlan{ // ordering is important here pb_lorawan.FrequencyPlan_EU_863_870, pb_lorawan.FrequencyPlan_IN_865_867, pb_lorawan.FrequencyP...
[ "func", "InitializeTables", "(", ")", "{", "initializeOnce", ".", "Do", "(", "func", "(", ")", "{", "frequencyPlans", "=", "make", "(", "map", "[", "string", "]", "FrequencyPlan", ")", "\n", "channels", "=", "make", "(", "map", "[", "int", "]", "string...
// InitializeTables initializes the frequency plan and channel tables.
[ "InitializeTables", "initializes", "the", "frequency", "plan", "and", "channel", "tables", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/band/band.go#L205-L234
22,915
TheThingsNetwork/ttn
ttnctl/util/discovery.go
GetDiscovery
func GetDiscovery(ctx ttnlog.Interface) (*grpc.ClientConn, discovery.DiscoveryClient) { path := path.Join(GetDataDir(), "/ca.cert") cert, err := ioutil.ReadFile(path) if err == nil && !pool.RootCAs.AppendCertsFromPEM(cert) { ctx.Warnf("Could not add root certificates from %s", path) } conn, err := api.Dial(vipe...
go
func GetDiscovery(ctx ttnlog.Interface) (*grpc.ClientConn, discovery.DiscoveryClient) { path := path.Join(GetDataDir(), "/ca.cert") cert, err := ioutil.ReadFile(path) if err == nil && !pool.RootCAs.AppendCertsFromPEM(cert) { ctx.Warnf("Could not add root certificates from %s", path) } conn, err := api.Dial(vipe...
[ "func", "GetDiscovery", "(", "ctx", "ttnlog", ".", "Interface", ")", "(", "*", "grpc", ".", "ClientConn", ",", "discovery", ".", "DiscoveryClient", ")", "{", "path", ":=", "path", ".", "Join", "(", "GetDataDir", "(", ")", ",", "\"", "\"", ")", "\n", ...
// GetDiscovery gets the Discovery client for ttnctl
[ "GetDiscovery", "gets", "the", "Discovery", "client", "for", "ttnctl" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/discovery.go#L19-L31
22,916
TheThingsNetwork/ttn
utils/security/generate_keys.go
GenerateKeypair
func GenerateKeypair(location string) error { // Generate private key key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { return err } privPEM, err := PrivatePEM(key) if err != nil { return err } pubPEM, err := PublicPEM(key) if err != nil { return err } err = ioutil.WriteFile...
go
func GenerateKeypair(location string) error { // Generate private key key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { return err } privPEM, err := PrivatePEM(key) if err != nil { return err } pubPEM, err := PublicPEM(key) if err != nil { return err } err = ioutil.WriteFile...
[ "func", "GenerateKeypair", "(", "location", "string", ")", "error", "{", "// Generate private key", "key", ",", "err", ":=", "ecdsa", ".", "GenerateKey", "(", "elliptic", ".", "P256", "(", ")", ",", "rand", ".", "Reader", ")", "\n", "if", "err", "!=", "n...
// GenerateKeypair generates a new keypair in the given location
[ "GenerateKeypair", "generates", "a", "new", "keypair", "in", "the", "given", "location" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/generate_keys.go#L25-L51
22,917
TheThingsNetwork/ttn
utils/security/generate_keys.go
GenerateCert
func GenerateCert(location string, commonName string, hostnames ...string) error { privKey, err := LoadKeypair(location) if err != nil { return err } // Build Certificate notBefore := time.Now() notAfter := notBefore.Add(validFor) serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err :=...
go
func GenerateCert(location string, commonName string, hostnames ...string) error { privKey, err := LoadKeypair(location) if err != nil { return err } // Build Certificate notBefore := time.Now() notAfter := notBefore.Add(validFor) serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) serialNumber, err :=...
[ "func", "GenerateCert", "(", "location", "string", ",", "commonName", "string", ",", "hostnames", "...", "string", ")", "error", "{", "privKey", ",", "err", ":=", "LoadKeypair", "(", "location", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", ...
// GenerateCert generates a certificate for the given hostnames in the given location
[ "GenerateCert", "generates", "a", "certificate", "for", "the", "given", "hostnames", "in", "the", "given", "location" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/generate_keys.go#L54-L105
22,918
TheThingsNetwork/ttn
core/discovery/announcement/migrate/announcement.go
AnnouncementMigrations
func AnnouncementMigrations(prefix string) map[string]storage.MigrateFunction { funcs := make(map[string]storage.MigrateFunction) for v, f := range announcementMigrations { funcs[v] = f(prefix) } return funcs }
go
func AnnouncementMigrations(prefix string) map[string]storage.MigrateFunction { funcs := make(map[string]storage.MigrateFunction) for v, f := range announcementMigrations { funcs[v] = f(prefix) } return funcs }
[ "func", "AnnouncementMigrations", "(", "prefix", "string", ")", "map", "[", "string", "]", "storage", ".", "MigrateFunction", "{", "funcs", ":=", "make", "(", "map", "[", "string", "]", "storage", ".", "MigrateFunction", ")", "\n", "for", "v", ",", "f", ...
// AnnouncementMigrations filled with the prefix
[ "AnnouncementMigrations", "filled", "with", "the", "prefix" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/announcement/migrate/announcement.go#L13-L19
22,919
TheThingsNetwork/ttn
utils/errors/errors.go
GetErrType
func GetErrType(err error) ErrType { switch errs.Cause(err).(type) { case *ErrAlreadyExists: return AlreadyExists case *ErrInternal: return Internal case *ErrInvalidArgument: return InvalidArgument case *ErrNotFound: return NotFound case *ErrPermissionDenied: return PermissionDenied } return Unknown }
go
func GetErrType(err error) ErrType { switch errs.Cause(err).(type) { case *ErrAlreadyExists: return AlreadyExists case *ErrInternal: return Internal case *ErrInvalidArgument: return InvalidArgument case *ErrNotFound: return NotFound case *ErrPermissionDenied: return PermissionDenied } return Unknown }
[ "func", "GetErrType", "(", "err", "error", ")", "ErrType", "{", "switch", "errs", ".", "Cause", "(", "err", ")", ".", "(", "type", ")", "{", "case", "*", "ErrAlreadyExists", ":", "return", "AlreadyExists", "\n", "case", "*", "ErrInternal", ":", "return",...
// GetErrType returns the type of err
[ "GetErrType", "returns", "the", "type", "of", "err" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/errors/errors.go#L31-L45
22,920
TheThingsNetwork/ttn
utils/errors/errors.go
BuildGRPCError
func BuildGRPCError(err error) error { if err == nil { return nil } code := grpc.Code(err) if code != codes.Unknown { return err // it already is a gRPC error } switch errs.Cause(err).(type) { case *ErrAlreadyExists: code = codes.AlreadyExists case *ErrInternal: code = codes.Internal case *ErrInvalidAr...
go
func BuildGRPCError(err error) error { if err == nil { return nil } code := grpc.Code(err) if code != codes.Unknown { return err // it already is a gRPC error } switch errs.Cause(err).(type) { case *ErrAlreadyExists: code = codes.AlreadyExists case *ErrInternal: code = codes.Internal case *ErrInvalidAr...
[ "func", "BuildGRPCError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "code", ":=", "grpc", ".", "Code", "(", "err", ")", "\n", "if", "code", "!=", "codes", ".", "Unknown", "{", "return",...
// BuildGRPCError returns the error with a GRPC code
[ "BuildGRPCError", "returns", "the", "error", "with", "a", "GRPC", "code" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/errors/errors.go#L73-L100
22,921
TheThingsNetwork/ttn
utils/errors/errors.go
FromGRPCError
func FromGRPCError(err error) error { if err == nil { return nil } if GetErrType(err) != Unknown { return err } code := grpc.Code(err) desc := grpc.ErrorDesc(err) switch code { case codes.AlreadyExists: return NewErrAlreadyExists(strings.TrimSuffix(desc, " already exists")) case codes.Internal: retur...
go
func FromGRPCError(err error) error { if err == nil { return nil } if GetErrType(err) != Unknown { return err } code := grpc.Code(err) desc := grpc.ErrorDesc(err) switch code { case codes.AlreadyExists: return NewErrAlreadyExists(strings.TrimSuffix(desc, " already exists")) case codes.Internal: retur...
[ "func", "FromGRPCError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "GetErrType", "(", "err", ")", "!=", "Unknown", "{", "return", "err", "\n", "}", "\n\n", "code", ":=", "grpc", ...
// FromGRPCError creates a regular error with the same type as the gRPC error
[ "FromGRPCError", "creates", "a", "regular", "error", "with", "the", "same", "type", "as", "the", "gRPC", "error" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/errors/errors.go#L103-L135
22,922
TheThingsNetwork/ttn
utils/errors/errors.go
NewErrInvalidArgument
func NewErrInvalidArgument(argument string, reason string) error { return &ErrInvalidArgument{argument: argument, reason: reason} }
go
func NewErrInvalidArgument(argument string, reason string) error { return &ErrInvalidArgument{argument: argument, reason: reason} }
[ "func", "NewErrInvalidArgument", "(", "argument", "string", ",", "reason", "string", ")", "error", "{", "return", "&", "ErrInvalidArgument", "{", "argument", ":", "argument", ",", "reason", ":", "reason", "}", "\n", "}" ]
// NewErrInvalidArgument returns a new ErrInvalidArgument for the given entitiy
[ "NewErrInvalidArgument", "returns", "a", "new", "ErrInvalidArgument", "for", "the", "given", "entitiy" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/errors/errors.go#L168-L170
22,923
TheThingsNetwork/ttn
utils/errors/errors.go
Wrapf
func Wrapf(err error, format string, args ...interface{}) error { return errs.Wrapf(err, format, args...) }
go
func Wrapf(err error, format string, args ...interface{}) error { return errs.Wrapf(err, format, args...) }
[ "func", "Wrapf", "(", "err", "error", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "errs", ".", "Wrapf", "(", "err", ",", "format", ",", "args", "...", ")", "\n", "}" ]
// Wrapf returns an error annotating err with the format specifier. // If err is nil, Wrapf returns nil.
[ "Wrapf", "returns", "an", "error", "annotating", "err", "with", "the", "format", "specifier", ".", "If", "err", "is", "nil", "Wrapf", "returns", "nil", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/errors/errors.go#L215-L217
22,924
TheThingsNetwork/ttn
utils/errors/errors.go
Wrap
func Wrap(err error, message string) error { return errs.Wrap(err, message) }
go
func Wrap(err error, message string) error { return errs.Wrap(err, message) }
[ "func", "Wrap", "(", "err", "error", ",", "message", "string", ")", "error", "{", "return", "errs", ".", "Wrap", "(", "err", ",", "message", ")", "\n", "}" ]
// Wrap returns an error annotating err with message. // If err is nil, Wrap returns nil.
[ "Wrap", "returns", "an", "error", "annotating", "err", "with", "message", ".", "If", "err", "is", "nil", "Wrap", "returns", "nil", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/errors/errors.go#L221-L223
22,925
TheThingsNetwork/ttn
core/storage/redis_store.go
NewRedisStore
func NewRedisStore(client *redis.Client, prefix string) *RedisStore { if !strings.HasSuffix(prefix, ":") { prefix += ":" } return &RedisStore{ client: client, prefix: prefix, } }
go
func NewRedisStore(client *redis.Client, prefix string) *RedisStore { if !strings.HasSuffix(prefix, ":") { prefix += ":" } return &RedisStore{ client: client, prefix: prefix, } }
[ "func", "NewRedisStore", "(", "client", "*", "redis", ".", "Client", ",", "prefix", "string", ")", "*", "RedisStore", "{", "if", "!", "strings", ".", "HasSuffix", "(", "prefix", ",", "\"", "\"", ")", "{", "prefix", "+=", "\"", "\"", "\n", "}", "\n", ...
// NewRedisStore creates a new RedisStore
[ "NewRedisStore", "creates", "a", "new", "RedisStore" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_store.go#L19-L27
22,926
TheThingsNetwork/ttn
core/storage/redis_store.go
Keys
func (s *RedisStore) Keys(selector string, opts *ListOptions) ([]string, error) { if opts != nil && opts.cacheKey != "" { cacheExists, err := s.client.Exists(opts.cacheKey).Result() if err != nil { return nil, err } if cacheExists { res, err := s.client.SMembers(opts.cacheKey).Result() if err == nil {...
go
func (s *RedisStore) Keys(selector string, opts *ListOptions) ([]string, error) { if opts != nil && opts.cacheKey != "" { cacheExists, err := s.client.Exists(opts.cacheKey).Result() if err != nil { return nil, err } if cacheExists { res, err := s.client.SMembers(opts.cacheKey).Result() if err == nil {...
[ "func", "(", "s", "*", "RedisStore", ")", "Keys", "(", "selector", "string", ",", "opts", "*", "ListOptions", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "opts", "!=", "nil", "&&", "opts", ".", "cacheKey", "!=", "\"", "\"", "{", "...
// Keys matching the selector, prepending the prefix to the selector if necessary
[ "Keys", "matching", "the", "selector", "prepending", "the", "prefix", "to", "the", "selector", "if", "necessary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_store.go#L30-L82
22,927
TheThingsNetwork/ttn
core/storage/redis_store.go
Count
func (s *RedisStore) Count(selector string, options *ListOptions) (int, error) { allKeys, err := s.Keys(selector, options) if err != nil { return 0, err } return len(allKeys), nil }
go
func (s *RedisStore) Count(selector string, options *ListOptions) (int, error) { allKeys, err := s.Keys(selector, options) if err != nil { return 0, err } return len(allKeys), nil }
[ "func", "(", "s", "*", "RedisStore", ")", "Count", "(", "selector", "string", ",", "options", "*", "ListOptions", ")", "(", "int", ",", "error", ")", "{", "allKeys", ",", "err", ":=", "s", ".", "Keys", "(", "selector", ",", "options", ")", "\n", "i...
// Count the results matching the selector
[ "Count", "the", "results", "matching", "the", "selector" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_store.go#L85-L91
22,928
TheThingsNetwork/ttn
core/storage/redis_store.go
Delete
func (s *RedisStore) Delete(key string) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } return s.client.Del(key).Err() }
go
func (s *RedisStore) Delete(key string) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } return s.client.Del(key).Err() }
[ "func", "(", "s", "*", "RedisStore", ")", "Delete", "(", "key", "string", ")", "error", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "s", ".", "prefix", "+", "key", "\n", "}", "\n", "re...
// Delete an existing record, prepending the prefix to the key if necessary
[ "Delete", "an", "existing", "record", "prepending", "the", "prefix", "to", "the", "key", "if", "necessary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_store.go#L94-L99
22,929
TheThingsNetwork/ttn
mqtt/client.go
Connect
func (c *DefaultClient) Connect() error { if c.mqtt.IsConnected() { return nil } var err error for retries := 0; retries < ConnectRetries; retries++ { token := c.mqtt.Connect() finished := token.WaitTimeout(1 * time.Second) if !finished { c.ctx.Warn("mqtt: connection took longer than expected...") tok...
go
func (c *DefaultClient) Connect() error { if c.mqtt.IsConnected() { return nil } var err error for retries := 0; retries < ConnectRetries; retries++ { token := c.mqtt.Connect() finished := token.WaitTimeout(1 * time.Second) if !finished { c.ctx.Warn("mqtt: connection took longer than expected...") tok...
[ "func", "(", "c", "*", "DefaultClient", ")", "Connect", "(", ")", "error", "{", "if", "c", ".", "mqtt", ".", "IsConnected", "(", ")", "{", "return", "nil", "\n", "}", "\n", "var", "err", "error", "\n", "for", "retries", ":=", "0", ";", "retries", ...
// Connect to the MQTT broker. It will retry for ConnectRetries times with a delay of ConnectRetryDelay between retries
[ "Connect", "to", "the", "MQTT", "broker", ".", "It", "will", "retry", "for", "ConnectRetries", "times", "with", "a", "delay", "of", "ConnectRetryDelay", "between", "retries" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/client.go#L214-L237
22,930
TheThingsNetwork/ttn
mqtt/client.go
Disconnect
func (c *DefaultClient) Disconnect() { if !c.mqtt.IsConnected() { return } c.ctx.Debug("mqtt: disconnecting") c.mqtt.Disconnect(25) }
go
func (c *DefaultClient) Disconnect() { if !c.mqtt.IsConnected() { return } c.ctx.Debug("mqtt: disconnecting") c.mqtt.Disconnect(25) }
[ "func", "(", "c", "*", "DefaultClient", ")", "Disconnect", "(", ")", "{", "if", "!", "c", ".", "mqtt", ".", "IsConnected", "(", ")", "{", "return", "\n", "}", "\n", "c", ".", "ctx", ".", "Debug", "(", "\"", "\"", ")", "\n", "c", ".", "mqtt", ...
// Disconnect from the MQTT broker
[ "Disconnect", "from", "the", "MQTT", "broker" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/client.go#L254-L260
22,931
TheThingsNetwork/ttn
ttnctl/util/lorawan.go
SetDevice
func (m *Message) SetDevice(devAddr types.DevAddr, nwkSKey types.NwkSKey, appSKey types.AppSKey) { m.devAddr = devAddr m.nwkSKey = nwkSKey m.appSKey = appSKey }
go
func (m *Message) SetDevice(devAddr types.DevAddr, nwkSKey types.NwkSKey, appSKey types.AppSKey) { m.devAddr = devAddr m.nwkSKey = nwkSKey m.appSKey = appSKey }
[ "func", "(", "m", "*", "Message", ")", "SetDevice", "(", "devAddr", "types", ".", "DevAddr", ",", "nwkSKey", "types", ".", "NwkSKey", ",", "appSKey", "types", ".", "AppSKey", ")", "{", "m", ".", "devAddr", "=", "devAddr", "\n", "m", ".", "nwkSKey", "...
// SetDevice with the LoRaWAN options
[ "SetDevice", "with", "the", "LoRaWAN", "options" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/lorawan.go#L27-L31
22,932
TheThingsNetwork/ttn
ttnctl/util/lorawan.go
SetMessage
func (m *Message) SetMessage(confirmed bool, ack bool, fCnt int, payload []byte) { m.confirmed = confirmed m.ack = ack m.FCnt = fCnt m.Payload = payload }
go
func (m *Message) SetMessage(confirmed bool, ack bool, fCnt int, payload []byte) { m.confirmed = confirmed m.ack = ack m.FCnt = fCnt m.Payload = payload }
[ "func", "(", "m", "*", "Message", ")", "SetMessage", "(", "confirmed", "bool", ",", "ack", "bool", ",", "fCnt", "int", ",", "payload", "[", "]", "byte", ")", "{", "m", ".", "confirmed", "=", "confirmed", "\n", "m", ".", "ack", "=", "ack", "\n", "...
// SetMessage with some options
[ "SetMessage", "with", "some", "options" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/lorawan.go#L34-L39
22,933
TheThingsNetwork/ttn
ttnctl/util/lorawan.go
Bytes
func (m *Message) Bytes() []byte { if m.FPort == 0 && len(m.Payload) > 0 { m.FPort = 1 } macPayload := &lorawan.MACPayload{} macPayload.FHDR = lorawan.FHDR{ DevAddr: lorawan.DevAddr(m.devAddr), FCnt: uint32(m.FCnt), FCtrl: lorawan.FCtrl{ ACK: m.ack, }, } macPayload.FPort = pointer.Uint8(uint8(m.FP...
go
func (m *Message) Bytes() []byte { if m.FPort == 0 && len(m.Payload) > 0 { m.FPort = 1 } macPayload := &lorawan.MACPayload{} macPayload.FHDR = lorawan.FHDR{ DevAddr: lorawan.DevAddr(m.devAddr), FCnt: uint32(m.FCnt), FCtrl: lorawan.FCtrl{ ACK: m.ack, }, } macPayload.FPort = pointer.Uint8(uint8(m.FP...
[ "func", "(", "m", "*", "Message", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "if", "m", ".", "FPort", "==", "0", "&&", "len", "(", "m", ".", "Payload", ")", ">", "0", "{", "m", ".", "FPort", "=", "1", "\n", "}", "\n", "macPayload", ":="...
// Bytes returns the bytes
[ "Bytes", "returns", "the", "bytes" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/lorawan.go#L42-L71
22,934
TheThingsNetwork/ttn
ttnctl/util/lorawan.go
Unmarshal
func (m *Message) Unmarshal(bytes []byte) error { payload := &lorawan.PHYPayload{} payload.UnmarshalBinary(bytes) if micOK, _ := payload.ValidateMIC(lorawan.AES128Key(m.nwkSKey)); !micOK { return errors.New("Invalid MIC") } macPayload, ok := payload.MACPayload.(*lorawan.MACPayload) if !ok { return errors.New(...
go
func (m *Message) Unmarshal(bytes []byte) error { payload := &lorawan.PHYPayload{} payload.UnmarshalBinary(bytes) if micOK, _ := payload.ValidateMIC(lorawan.AES128Key(m.nwkSKey)); !micOK { return errors.New("Invalid MIC") } macPayload, ok := payload.MACPayload.(*lorawan.MACPayload) if !ok { return errors.New(...
[ "func", "(", "m", "*", "Message", ")", "Unmarshal", "(", "bytes", "[", "]", "byte", ")", "error", "{", "payload", ":=", "&", "lorawan", ".", "PHYPayload", "{", "}", "\n", "payload", ".", "UnmarshalBinary", "(", "bytes", ")", "\n", "if", "micOK", ",",...
// Unmarshal a byte slice into a Message
[ "Unmarshal", "a", "byte", "slice", "into", "a", "Message" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/lorawan.go#L74-L95
22,935
TheThingsNetwork/ttn
utils/parse/parse.go
Port
func Port(address string) (uint, error) { parts := strings.Split(address, ":") length := len(parts) if length < 2 { return 0, errors.New("Could not parse the port: malformated address") } port, err := strconv.Atoi(parts[length-1]) if err != nil { return 0, err } if port < 0 { return 0, errors.New("Inval...
go
func Port(address string) (uint, error) { parts := strings.Split(address, ":") length := len(parts) if length < 2 { return 0, errors.New("Could not parse the port: malformated address") } port, err := strconv.Atoi(parts[length-1]) if err != nil { return 0, err } if port < 0 { return 0, errors.New("Inval...
[ "func", "Port", "(", "address", "string", ")", "(", "uint", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "address", ",", "\"", "\"", ")", "\n\n", "length", ":=", "len", "(", "parts", ")", "\n", "if", "length", "<", "2", "{...
// Port returns the port from an address
[ "Port", "returns", "the", "port", "from", "an", "address" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/parse/parse.go#L10-L27
22,936
TheThingsNetwork/ttn
core/handler/device/store.go
NewRedisDeviceStore
func NewRedisDeviceStore(client *redis.Client, prefix string) *RedisDeviceStore { if prefix == "" { prefix = defaultRedisPrefix } store := storage.NewRedisMapStore(client, prefix+":"+redisDevicePrefix) store.SetBase(Device{}, "") for v, f := range migrate.DeviceMigrations(prefix) { store.AddMigration(v, f) } ...
go
func NewRedisDeviceStore(client *redis.Client, prefix string) *RedisDeviceStore { if prefix == "" { prefix = defaultRedisPrefix } store := storage.NewRedisMapStore(client, prefix+":"+redisDevicePrefix) store.SetBase(Device{}, "") for v, f := range migrate.DeviceMigrations(prefix) { store.AddMigration(v, f) } ...
[ "func", "NewRedisDeviceStore", "(", "client", "*", "redis", ".", "Client", ",", "prefix", "string", ")", "*", "RedisDeviceStore", "{", "if", "prefix", "==", "\"", "\"", "{", "prefix", "=", "defaultRedisPrefix", "\n", "}", "\n", "store", ":=", "storage", "....
// NewRedisDeviceStore creates a new Redis-based Device store
[ "NewRedisDeviceStore", "creates", "a", "new", "Redis", "-", "based", "Device", "store" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/store.go#L49-L68
22,937
TheThingsNetwork/ttn
core/handler/device/store.go
Count
func (s *RedisDeviceStore) Count() (int, error) { opts := new(storage.ListOptions) opts.UseCache(s.listResultCacheKey("_all_"), listCacheTTL) return s.store.Count("", opts) }
go
func (s *RedisDeviceStore) Count() (int, error) { opts := new(storage.ListOptions) opts.UseCache(s.listResultCacheKey("_all_"), listCacheTTL) return s.store.Count("", opts) }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "Count", "(", ")", "(", "int", ",", "error", ")", "{", "opts", ":=", "new", "(", "storage", ".", "ListOptions", ")", "\n", "opts", ".", "UseCache", "(", "s", ".", "listResultCacheKey", "(", "\"", "\"", ...
// Count all devices in the store
[ "Count", "all", "devices", "in", "the", "store" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/store.go#L87-L91
22,938
TheThingsNetwork/ttn
core/handler/device/store.go
CountForApp
func (s *RedisDeviceStore) CountForApp(appID string) (int, error) { opts := new(storage.ListOptions) opts.UseCache(s.listResultCacheKey(appID), listCacheTTL) return s.store.Count(fmt.Sprintf("%s:*", appID), opts) }
go
func (s *RedisDeviceStore) CountForApp(appID string) (int, error) { opts := new(storage.ListOptions) opts.UseCache(s.listResultCacheKey(appID), listCacheTTL) return s.store.Count(fmt.Sprintf("%s:*", appID), opts) }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "CountForApp", "(", "appID", "string", ")", "(", "int", ",", "error", ")", "{", "opts", ":=", "new", "(", "storage", ".", "ListOptions", ")", "\n", "opts", ".", "UseCache", "(", "s", ".", "listResultCache...
// CountForApp counts all devices for an Application
[ "CountForApp", "counts", "all", "devices", "for", "an", "Application" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/store.go#L94-L98
22,939
TheThingsNetwork/ttn
core/handler/device/store.go
List
func (s *RedisDeviceStore) List(opts *storage.ListOptions) ([]*Device, error) { if opts == nil { opts = new(storage.ListOptions) } opts.UseCache(s.listResultCacheKey("_all_"), listCacheTTL) devicesI, err := s.store.List("", opts) if err != nil { return nil, err } devices := make([]*Device, len(devicesI)) fo...
go
func (s *RedisDeviceStore) List(opts *storage.ListOptions) ([]*Device, error) { if opts == nil { opts = new(storage.ListOptions) } opts.UseCache(s.listResultCacheKey("_all_"), listCacheTTL) devicesI, err := s.store.List("", opts) if err != nil { return nil, err } devices := make([]*Device, len(devicesI)) fo...
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "List", "(", "opts", "*", "storage", ".", "ListOptions", ")", "(", "[", "]", "*", "Device", ",", "error", ")", "{", "if", "opts", "==", "nil", "{", "opts", "=", "new", "(", "storage", ".", "ListOption...
// List all Devices
[ "List", "all", "Devices" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/store.go#L101-L117
22,940
TheThingsNetwork/ttn
core/handler/device/store.go
DownlinkQueue
func (s *RedisDeviceStore) DownlinkQueue(appID, devID string) (DownlinkQueue, error) { return &RedisDownlinkQueue{ appID: appID, devID: devID, queues: s.queues, }, nil }
go
func (s *RedisDeviceStore) DownlinkQueue(appID, devID string) (DownlinkQueue, error) { return &RedisDownlinkQueue{ appID: appID, devID: devID, queues: s.queues, }, nil }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "DownlinkQueue", "(", "appID", ",", "devID", "string", ")", "(", "DownlinkQueue", ",", "error", ")", "{", "return", "&", "RedisDownlinkQueue", "{", "appID", ":", "appID", ",", "devID", ":", "devID", ",", "q...
// DownlinkQueue for a specific Device
[ "DownlinkQueue", "for", "a", "specific", "Device" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/store.go#L151-L157
22,941
TheThingsNetwork/ttn
core/handler/device/store.go
AddBuiltinAttribute
func (s *RedisDeviceStore) AddBuiltinAttribute(attr ...string) { s.builtinAttibutes = append(s.builtinAttibutes, attr...) sort.Strings(s.builtinAttibutes) }
go
func (s *RedisDeviceStore) AddBuiltinAttribute(attr ...string) { s.builtinAttibutes = append(s.builtinAttibutes, attr...) sort.Strings(s.builtinAttibutes) }
[ "func", "(", "s", "*", "RedisDeviceStore", ")", "AddBuiltinAttribute", "(", "attr", "...", "string", ")", "{", "s", ".", "builtinAttibutes", "=", "append", "(", "s", ".", "builtinAttibutes", ",", "attr", "...", ")", "\n", "sort", ".", "Strings", "(", "s"...
// AddBuiltinAttribute adds builtin device attributes to the list.
[ "AddBuiltinAttribute", "adds", "builtin", "device", "attributes", "to", "the", "list", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/store.go#L208-L211
22,942
TheThingsNetwork/ttn
core/component/config.go
ConfigFromViper
func ConfigFromViper() Config { return Config{ AuthServers: viper.GetStringMapString("auth-servers"), KeyDir: viper.GetString("key-dir"), UseTLS: viper.GetBool("tls"), MinTLSVersion: viper.GetString("min-tls-version"), } }
go
func ConfigFromViper() Config { return Config{ AuthServers: viper.GetStringMapString("auth-servers"), KeyDir: viper.GetString("key-dir"), UseTLS: viper.GetBool("tls"), MinTLSVersion: viper.GetString("min-tls-version"), } }
[ "func", "ConfigFromViper", "(", ")", "Config", "{", "return", "Config", "{", "AuthServers", ":", "viper", ".", "GetStringMapString", "(", "\"", "\"", ")", ",", "KeyDir", ":", "viper", ".", "GetString", "(", "\"", "\"", ")", ",", "UseTLS", ":", "viper", ...
// ConfigFromViper imports configuration from Viper
[ "ConfigFromViper", "imports", "configuration", "from", "Viper" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/config.go#L19-L26
22,943
TheThingsNetwork/ttn
amqp/publisher.go
NewPublisher
func (c *DefaultClient) NewPublisher(exchange string) Publisher { return &DefaultPublisher{ DefaultChannelClient: DefaultChannelClient{ ctx: c.ctx, client: c, exchange: exchange, name: "Publisher", }, } }
go
func (c *DefaultClient) NewPublisher(exchange string) Publisher { return &DefaultPublisher{ DefaultChannelClient: DefaultChannelClient{ ctx: c.ctx, client: c, exchange: exchange, name: "Publisher", }, } }
[ "func", "(", "c", "*", "DefaultClient", ")", "NewPublisher", "(", "exchange", "string", ")", "Publisher", "{", "return", "&", "DefaultPublisher", "{", "DefaultChannelClient", ":", "DefaultChannelClient", "{", "ctx", ":", "c", ".", "ctx", ",", "client", ":", ...
// NewPublisher returns a new topic publisher on the specified exchange
[ "NewPublisher", "returns", "a", "new", "topic", "publisher", "on", "the", "specified", "exchange" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/publisher.go#L29-L38
22,944
TheThingsNetwork/ttn
mqtt/topics.go
ParseDeviceTopic
func ParseDeviceTopic(topic string) (*DeviceTopic, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\+)/(devices)/([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\+)/(events|up|down)([0-9a-z/]+)?$") matches := pattern.FindStringSubmatch(topic) if len(matches) < 5 { return nil, fmt.Errorf("Invalid topic...
go
func ParseDeviceTopic(topic string) (*DeviceTopic, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\+)/(devices)/([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\+)/(events|up|down)([0-9a-z/]+)?$") matches := pattern.FindStringSubmatch(topic) if len(matches) < 5 { return nil, fmt.Errorf("Invalid topic...
[ "func", "ParseDeviceTopic", "(", "topic", "string", ")", "(", "*", "DeviceTopic", ",", "error", ")", "{", "pattern", ":=", "regexp", ".", "MustCompile", "(", "\"", "\\\\", "\\\\", "\"", ")", "\n", "matches", ":=", "pattern", ".", "FindStringSubmatch", "(",...
// ParseDeviceTopic parses an MQTT device topic string to a DeviceTopic struct
[ "ParseDeviceTopic", "parses", "an", "MQTT", "device", "topic", "string", "to", "a", "DeviceTopic", "struct" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/topics.go#L34-L54
22,945
TheThingsNetwork/ttn
mqtt/topics.go
ParseApplicationTopic
func ParseApplicationTopic(topic string) (*ApplicationTopic, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\+)/(events)([0-9a-z/-]+|/#)?$") matches := pattern.FindStringSubmatch(topic) if len(matches) < 3 { return nil, fmt.Errorf("Invalid topic format") } var appID string if matches...
go
func ParseApplicationTopic(topic string) (*ApplicationTopic, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\+)/(events)([0-9a-z/-]+|/#)?$") matches := pattern.FindStringSubmatch(topic) if len(matches) < 3 { return nil, fmt.Errorf("Invalid topic format") } var appID string if matches...
[ "func", "ParseApplicationTopic", "(", "topic", "string", ")", "(", "*", "ApplicationTopic", ",", "error", ")", "{", "pattern", ":=", "regexp", ".", "MustCompile", "(", "\"", "\\\\", "\"", ")", "\n", "matches", ":=", "pattern", ".", "FindStringSubmatch", "(",...
// ParseApplicationTopic parses an MQTT device topic string to an ApplicationTopic struct
[ "ParseApplicationTopic", "parses", "an", "MQTT", "device", "topic", "string", "to", "an", "ApplicationTopic", "struct" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/topics.go#L92-L108
22,946
TheThingsNetwork/ttn
core/handler/dry_run.go
DryUplink
func (h *handlerManager) DryUplink(ctx context.Context, in *pb.DryUplinkMessage) (*pb.DryUplinkResult, error) { app := in.App flds := "" valid := true var logs []*pb.LogEntry var decoder PayloadDecoder switch application.PayloadFormat(app.PayloadFormat) { case "", application.PayloadFormatCustom: decoder = &C...
go
func (h *handlerManager) DryUplink(ctx context.Context, in *pb.DryUplinkMessage) (*pb.DryUplinkResult, error) { app := in.App flds := "" valid := true var logs []*pb.LogEntry var decoder PayloadDecoder switch application.PayloadFormat(app.PayloadFormat) { case "", application.PayloadFormatCustom: decoder = &C...
[ "func", "(", "h", "*", "handlerManager", ")", "DryUplink", "(", "ctx", "context", ".", "Context", ",", "in", "*", "pb", ".", "DryUplinkMessage", ")", "(", "*", "pb", ".", "DryUplinkResult", ",", "error", ")", "{", "app", ":=", "in", ".", "App", "\n\n...
// DryUplink converts the uplink message payload by running the payload // functions that are provided in the DryUplinkMessage, without actually going to the network. // This is helpful for testing the payload functions without having to save them.
[ "DryUplink", "converts", "the", "uplink", "message", "payload", "by", "running", "the", "payload", "functions", "that", "are", "provided", "in", "the", "DryUplinkMessage", "without", "actually", "going", "to", "the", "network", ".", "This", "is", "helpful", "for...
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/dry_run.go#L20-L62
22,947
TheThingsNetwork/ttn
core/handler/dry_run.go
DryDownlink
func (h *handlerManager) DryDownlink(ctx context.Context, in *pb.DryDownlinkMessage) (*pb.DryDownlinkResult, error) { app := in.App if in.Payload != nil { if in.Fields != "" { return nil, errors.NewErrInvalidArgument("Downlink", "Both Fields and Payload provided") } return &pb.DryDownlinkResult{ Payload:...
go
func (h *handlerManager) DryDownlink(ctx context.Context, in *pb.DryDownlinkMessage) (*pb.DryDownlinkResult, error) { app := in.App if in.Payload != nil { if in.Fields != "" { return nil, errors.NewErrInvalidArgument("Downlink", "Both Fields and Payload provided") } return &pb.DryDownlinkResult{ Payload:...
[ "func", "(", "h", "*", "handlerManager", ")", "DryDownlink", "(", "ctx", "context", ".", "Context", ",", "in", "*", "pb", ".", "DryDownlinkMessage", ")", "(", "*", "pb", ".", "DryDownlinkResult", ",", "error", ")", "{", "app", ":=", "in", ".", "App", ...
// DryDownlink converts the downlink message payload by running the payload // functions that are provided in the DryDownlinkMessage, without actually going to the network. // This is helpful for testing the payload functions without having to save them.
[ "DryDownlink", "converts", "the", "downlink", "message", "payload", "by", "running", "the", "payload", "functions", "that", "are", "provided", "in", "the", "DryDownlinkMessage", "without", "actually", "going", "to", "the", "network", ".", "This", "is", "helpful", ...
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/dry_run.go#L67-L111
22,948
TheThingsNetwork/ttn
amqp/routing_keys.go
ParseDeviceKey
func ParseDeviceKey(key string) (*DeviceKey, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\*)\\.(devices)\\.([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\*)\\.(events|up|down)([0-9a-z\\.]+)?$") matches := pattern.FindStringSubmatch(key) if len(matches) < 5 { return nil, fmt.Errorf("Invalid key f...
go
func ParseDeviceKey(key string) (*DeviceKey, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\*)\\.(devices)\\.([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\*)\\.(events|up|down)([0-9a-z\\.]+)?$") matches := pattern.FindStringSubmatch(key) if len(matches) < 5 { return nil, fmt.Errorf("Invalid key f...
[ "func", "ParseDeviceKey", "(", "key", "string", ")", "(", "*", "DeviceKey", ",", "error", ")", "{", "pattern", ":=", "regexp", ".", "MustCompile", "(", "\"", "\\\\", "\\\\", "\\\\", "\\\\", "\\\\", "\\\\", "\"", ")", "\n", "matches", ":=", "pattern", "...
// ParseDeviceKey parses an AMQP device routing key string to a DeviceKey struct
[ "ParseDeviceKey", "parses", "an", "AMQP", "device", "routing", "key", "string", "to", "a", "DeviceKey", "struct" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/routing_keys.go#L34-L54
22,949
TheThingsNetwork/ttn
amqp/routing_keys.go
ParseApplicationKey
func ParseApplicationKey(key string) (*ApplicationKey, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\*)\\.(events)([0-9a-z\\.-]+|\\.#)?$") matches := pattern.FindStringSubmatch(key) if len(matches) < 3 { return nil, fmt.Errorf("Invalid key format") } var appID string if matches[1] ...
go
func ParseApplicationKey(key string) (*ApplicationKey, error) { pattern := regexp.MustCompile("^([0-9a-z](?:[_-]?[0-9a-z]){1,35}|\\*)\\.(events)([0-9a-z\\.-]+|\\.#)?$") matches := pattern.FindStringSubmatch(key) if len(matches) < 3 { return nil, fmt.Errorf("Invalid key format") } var appID string if matches[1] ...
[ "func", "ParseApplicationKey", "(", "key", "string", ")", "(", "*", "ApplicationKey", ",", "error", ")", "{", "pattern", ":=", "regexp", ".", "MustCompile", "(", "\"", "\\\\", "\\\\", "\\\\", "\\\\", "\"", ")", "\n", "matches", ":=", "pattern", ".", "Fin...
// ParseApplicationKey parses an AMQP application routing key string to an ApplicationKey struct
[ "ParseApplicationKey", "parses", "an", "AMQP", "application", "routing", "key", "string", "to", "an", "ApplicationKey", "struct" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/routing_keys.go#L92-L108
22,950
TheThingsNetwork/ttn
amqp/client.go
Connect
func (c *DefaultClient) Connect() error { _, err := c.connect(false) return err }
go
func (c *DefaultClient) Connect() error { _, err := c.connect(false) return err }
[ "func", "(", "c", "*", "DefaultClient", ")", "Connect", "(", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "connect", "(", "false", ")", "\n", "return", "err", "\n", "}" ]
// Connect to the AMQP server. It will retry for ConnectRetries times with a delay of ConnectRetryDelay between retries
[ "Connect", "to", "the", "AMQP", "server", ".", "It", "will", "retry", "for", "ConnectRetries", "times", "with", "a", "delay", "of", "ConnectRetryDelay", "between", "retries" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/client.go#L148-L151
22,951
TheThingsNetwork/ttn
amqp/client.go
Disconnect
func (c *DefaultClient) Disconnect() { if !c.IsConnected() { return } c.ctx.Debug("Disconnecting from AMQP") c.mutex.Lock() defer c.mutex.Unlock() for user, channel := range c.channels { channel.Close() delete(c.channels, user) } c.conn.Close() c.conn = nil }
go
func (c *DefaultClient) Disconnect() { if !c.IsConnected() { return } c.ctx.Debug("Disconnecting from AMQP") c.mutex.Lock() defer c.mutex.Unlock() for user, channel := range c.channels { channel.Close() delete(c.channels, user) } c.conn.Close() c.conn = nil }
[ "func", "(", "c", "*", "DefaultClient", ")", "Disconnect", "(", ")", "{", "if", "!", "c", ".", "IsConnected", "(", ")", "{", "return", "\n", "}", "\n\n", "c", ".", "ctx", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "c", ".", "mutex", ".", "Lock...
// Disconnect from the AMQP server
[ "Disconnect", "from", "the", "AMQP", "server" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/client.go#L154-L170
22,952
TheThingsNetwork/ttn
amqp/client.go
Open
func (p *DefaultChannelClient) Open() error { channel, err := p.client.openChannel(p) if err != nil { return fmt.Errorf("Could not open AMQP channel (%s)", err) } p.channel = channel return nil }
go
func (p *DefaultChannelClient) Open() error { channel, err := p.client.openChannel(p) if err != nil { return fmt.Errorf("Could not open AMQP channel (%s)", err) } p.channel = channel return nil }
[ "func", "(", "p", "*", "DefaultChannelClient", ")", "Open", "(", ")", "error", "{", "channel", ",", "err", ":=", "p", ".", "client", ".", "openChannel", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", ...
// Open opens a new channel and declares the exchange
[ "Open", "opens", "a", "new", "channel", "and", "declares", "the", "exchange" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/client.go#L205-L213
22,953
TheThingsNetwork/ttn
amqp/client.go
Close
func (p *DefaultChannelClient) Close() error { p.usersMutex.RLock() defer p.usersMutex.RUnlock() for _, user := range p.users { user.close() } return p.client.closeChannel(p) }
go
func (p *DefaultChannelClient) Close() error { p.usersMutex.RLock() defer p.usersMutex.RUnlock() for _, user := range p.users { user.close() } return p.client.closeChannel(p) }
[ "func", "(", "p", "*", "DefaultChannelClient", ")", "Close", "(", ")", "error", "{", "p", ".", "usersMutex", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "usersMutex", ".", "RUnlock", "(", ")", "\n", "for", "_", ",", "user", ":=", "range", "p",...
// Close closes the channel
[ "Close", "closes", "the", "channel" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/client.go#L216-L223
22,954
TheThingsNetwork/ttn
core/types/eui.go
ParseEUI64
func ParseEUI64(input string) (eui EUI64, err error) { bytes, err := ParseHEX(input, 8) if err != nil { return } copy(eui[:], bytes) return }
go
func ParseEUI64(input string) (eui EUI64, err error) { bytes, err := ParseHEX(input, 8) if err != nil { return } copy(eui[:], bytes) return }
[ "func", "ParseEUI64", "(", "input", "string", ")", "(", "eui", "EUI64", ",", "err", "error", ")", "{", "bytes", ",", "err", ":=", "ParseHEX", "(", "input", ",", "8", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "copy", "("...
// ParseEUI64 parses a 64-bit hex-encoded string to an EUI64.
[ "ParseEUI64", "parses", "a", "64", "-", "bit", "hex", "-", "encoded", "string", "to", "an", "EUI64", "." ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/eui.go#L23-L30
22,955
TheThingsNetwork/ttn
core/types/eui.go
ParseAppEUI
func ParseAppEUI(input string) (eui AppEUI, err error) { eui64, err := ParseEUI64(input) if err != nil { return } eui = AppEUI(eui64) return }
go
func ParseAppEUI(input string) (eui AppEUI, err error) { eui64, err := ParseEUI64(input) if err != nil { return } eui = AppEUI(eui64) return }
[ "func", "ParseAppEUI", "(", "input", "string", ")", "(", "eui", "AppEUI", ",", "err", "error", ")", "{", "eui64", ",", "err", ":=", "ParseEUI64", "(", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "eui", "=", "AppEUI...
// ParseAppEUI parses a 64-bit hex-encoded string to an AppEUI
[ "ParseAppEUI", "parses", "a", "64", "-", "bit", "hex", "-", "encoded", "string", "to", "an", "AppEUI" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/eui.go#L106-L113
22,956
TheThingsNetwork/ttn
core/types/eui.go
ParseDevEUI
func ParseDevEUI(input string) (eui DevEUI, err error) { eui64, err := ParseEUI64(input) if err != nil { return } eui = DevEUI(eui64) return }
go
func ParseDevEUI(input string) (eui DevEUI, err error) { eui64, err := ParseEUI64(input) if err != nil { return } eui = DevEUI(eui64) return }
[ "func", "ParseDevEUI", "(", "input", "string", ")", "(", "eui", "DevEUI", ",", "err", "error", ")", "{", "eui64", ",", "err", ":=", "ParseEUI64", "(", "input", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "eui", "=", "DevEUI...
// ParseDevEUI parses a 64-bit hex-encoded string to an DevEUI
[ "ParseDevEUI", "parses", "a", "64", "-", "bit", "hex", "-", "encoded", "string", "to", "an", "DevEUI" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/eui.go#L190-L197
22,957
TheThingsNetwork/ttn
amqp/uplink.go
PublishUplink
func (c *DefaultPublisher) PublishUplink(dataUp types.UplinkMessage) error { key := DeviceKey{dataUp.AppID, dataUp.DevID, DeviceUplink, ""} msg, err := json.Marshal(dataUp) if err != nil { return fmt.Errorf("Unable to marshal the message payload: %s", err) } return c.publish(key.String(), msg, time.Time(dataUp.M...
go
func (c *DefaultPublisher) PublishUplink(dataUp types.UplinkMessage) error { key := DeviceKey{dataUp.AppID, dataUp.DevID, DeviceUplink, ""} msg, err := json.Marshal(dataUp) if err != nil { return fmt.Errorf("Unable to marshal the message payload: %s", err) } return c.publish(key.String(), msg, time.Time(dataUp.M...
[ "func", "(", "c", "*", "DefaultPublisher", ")", "PublishUplink", "(", "dataUp", "types", ".", "UplinkMessage", ")", "error", "{", "key", ":=", "DeviceKey", "{", "dataUp", ".", "AppID", ",", "dataUp", ".", "DevID", ",", "DeviceUplink", ",", "\"", "\"", "}...
// PublishUplink publishes an uplink message to the AMQP broker
[ "PublishUplink", "publishes", "an", "uplink", "message", "to", "the", "AMQP", "broker" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/uplink.go#L20-L27
22,958
TheThingsNetwork/ttn
amqp/uplink.go
ConsumeUplink
func (s *DefaultSubscriber) ConsumeUplink(queue string, handler UplinkHandler) error { messages, err := s.consume(s.name) if err != nil { return err } go s.handleUplink(messages, handler) return nil }
go
func (s *DefaultSubscriber) ConsumeUplink(queue string, handler UplinkHandler) error { messages, err := s.consume(s.name) if err != nil { return err } go s.handleUplink(messages, handler) return nil }
[ "func", "(", "s", "*", "DefaultSubscriber", ")", "ConsumeUplink", "(", "queue", "string", ",", "handler", "UplinkHandler", ")", "error", "{", "messages", ",", "err", ":=", "s", ".", "consume", "(", "s", ".", "name", ")", "\n", "if", "err", "!=", "nil",...
// ConsumeUplink consumes uplink messages in a specific queue
[ "ConsumeUplink", "consumes", "uplink", "messages", "in", "a", "specific", "queue" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/uplink.go#L56-L64
22,959
TheThingsNetwork/ttn
utils/waitgroup.go
WaitForMax
func (wg *WaitGroup) WaitForMax(d time.Duration) error { waitChan := make(chan struct{}) go func() { atomic.AddInt32(&waiting, 1) wg.Wait() atomic.AddInt32(&waiting, -1) close(waitChan) }() select { case <-waitChan: return nil case <-time.After(d): return errors.New("Wait timeout expired") } }
go
func (wg *WaitGroup) WaitForMax(d time.Duration) error { waitChan := make(chan struct{}) go func() { atomic.AddInt32(&waiting, 1) wg.Wait() atomic.AddInt32(&waiting, -1) close(waitChan) }() select { case <-waitChan: return nil case <-time.After(d): return errors.New("Wait timeout expired") } }
[ "func", "(", "wg", "*", "WaitGroup", ")", "WaitForMax", "(", "d", "time", ".", "Duration", ")", "error", "{", "waitChan", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "go", "func", "(", ")", "{", "atomic", ".", "AddInt32", "(", "&", ...
// WaitForMax waits until the WaitGroup is Done or the specified duration has elapsed
[ "WaitForMax", "waits", "until", "the", "WaitGroup", "is", "Done", "or", "the", "specified", "duration", "has", "elapsed" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/waitgroup.go#L22-L36
22,960
TheThingsNetwork/ttn
core/storage/redis_queue_store.go
NewRedisQueueStore
func NewRedisQueueStore(client *redis.Client, prefix string) *RedisQueueStore { if !strings.HasSuffix(prefix, ":") { prefix += ":" } return &RedisQueueStore{ RedisStore: NewRedisStore(client, prefix), } }
go
func NewRedisQueueStore(client *redis.Client, prefix string) *RedisQueueStore { if !strings.HasSuffix(prefix, ":") { prefix += ":" } return &RedisQueueStore{ RedisStore: NewRedisStore(client, prefix), } }
[ "func", "NewRedisQueueStore", "(", "client", "*", "redis", ".", "Client", ",", "prefix", "string", ")", "*", "RedisQueueStore", "{", "if", "!", "strings", ".", "HasSuffix", "(", "prefix", ",", "\"", "\"", ")", "{", "prefix", "+=", "\"", "\"", "\n", "}"...
// NewRedisQueueStore creates a new RedisQueueStore
[ "NewRedisQueueStore", "creates", "a", "new", "RedisQueueStore" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_queue_store.go#L19-L26
22,961
TheThingsNetwork/ttn
core/storage/redis_queue_store.go
Get
func (s *RedisQueueStore) Get(key string) (res []string, err error) { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } res, err = s.client.LRange(key, 0, -1).Result() if err == redis.Nil { return res, nil } return res, err }
go
func (s *RedisQueueStore) Get(key string) (res []string, err error) { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } res, err = s.client.LRange(key, 0, -1).Result() if err == redis.Nil { return res, nil } return res, err }
[ "func", "(", "s", "*", "RedisQueueStore", ")", "Get", "(", "key", "string", ")", "(", "res", "[", "]", "string", ",", "err", "error", ")", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "...
// Get one result, prepending the prefix to the key if necessary // The items remain in the queue after the Get operation
[ "Get", "one", "result", "prepending", "the", "prefix", "to", "the", "key", "if", "necessary", "The", "items", "remain", "in", "the", "queue", "after", "the", "Get", "operation" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_queue_store.go#L85-L94
22,962
TheThingsNetwork/ttn
core/storage/redis_queue_store.go
Length
func (s *RedisQueueStore) Length(key string) (int, error) { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } res, err := s.client.LLen(key).Result() if err == redis.Nil { return int(res), nil } return int(res), err }
go
func (s *RedisQueueStore) Length(key string) (int, error) { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } res, err := s.client.LLen(key).Result() if err == redis.Nil { return int(res), nil } return int(res), err }
[ "func", "(", "s", "*", "RedisQueueStore", ")", "Length", "(", "key", "string", ")", "(", "int", ",", "error", ")", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "s", ".", "prefix", "+", ...
// Length gets the size of a queue, prepending the prefix to the key if necessary
[ "Length", "gets", "the", "size", "of", "a", "queue", "prepending", "the", "prefix", "to", "the", "key", "if", "necessary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_queue_store.go#L97-L106
22,963
TheThingsNetwork/ttn
core/storage/redis_queue_store.go
Next
func (s *RedisQueueStore) Next(key string) (string, error) { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } res, err := s.client.LPop(key).Result() if err == redis.Nil { return "", nil } return res, err }
go
func (s *RedisQueueStore) Next(key string) (string, error) { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } res, err := s.client.LPop(key).Result() if err == redis.Nil { return "", nil } return res, err }
[ "func", "(", "s", "*", "RedisQueueStore", ")", "Next", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "s", ".", "prefix", "+", ...
// Next removes the first element from the queue and returns it, prepending the prefix to the key if necessary
[ "Next", "removes", "the", "first", "element", "from", "the", "queue", "and", "returns", "it", "prepending", "the", "prefix", "to", "the", "key", "if", "necessary" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_queue_store.go#L161-L170
22,964
TheThingsNetwork/ttn
core/storage/redis_queue_store.go
Trim
func (s *RedisQueueStore) Trim(key string, length int) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } err := s.client.LTrim(key, 0, int64(length-1)).Err() if err == redis.Nil { return nil } return err }
go
func (s *RedisQueueStore) Trim(key string, length int) error { if !strings.HasPrefix(key, s.prefix) { key = s.prefix + key } err := s.client.LTrim(key, 0, int64(length-1)).Err() if err == redis.Nil { return nil } return err }
[ "func", "(", "s", "*", "RedisQueueStore", ")", "Trim", "(", "key", "string", ",", "length", "int", ")", "error", "{", "if", "!", "strings", ".", "HasPrefix", "(", "key", ",", "s", ".", "prefix", ")", "{", "key", "=", "s", ".", "prefix", "+", "key...
// Trim the length of the queue
[ "Trim", "the", "length", "of", "the", "queue" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/storage/redis_queue_store.go#L173-L182
22,965
TheThingsNetwork/ttn
core/component/discovery.go
Discover
func (c *Component) Discover(serviceName, id string) (*pb_discovery.Announcement, error) { res, err := c.Discovery.Get(serviceName, id) if err != nil { return nil, errors.Wrapf(errors.FromGRPCError(err), "Failed to discover %s/%s", serviceName, id) } return res, nil }
go
func (c *Component) Discover(serviceName, id string) (*pb_discovery.Announcement, error) { res, err := c.Discovery.Get(serviceName, id) if err != nil { return nil, errors.Wrapf(errors.FromGRPCError(err), "Failed to discover %s/%s", serviceName, id) } return res, nil }
[ "func", "(", "c", "*", "Component", ")", "Discover", "(", "serviceName", ",", "id", "string", ")", "(", "*", "pb_discovery", ".", "Announcement", ",", "error", ")", "{", "res", ",", "err", ":=", "c", ".", "Discovery", ".", "Get", "(", "serviceName", ...
// Discover is used to discover another component
[ "Discover", "is", "used", "to", "discover", "another", "component" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/discovery.go#L12-L18
22,966
TheThingsNetwork/ttn
core/component/discovery.go
Announce
func (c *Component) Announce() error { if c.Identity.ID == "" { return errors.NewErrInvalidArgument("Component ID", "can not be empty") } err := c.Discovery.Announce(c.AccessToken) if err != nil { return errors.Wrapf(errors.FromGRPCError(err), "Failed to announce this component to TTN discovery: %s", err.Error(...
go
func (c *Component) Announce() error { if c.Identity.ID == "" { return errors.NewErrInvalidArgument("Component ID", "can not be empty") } err := c.Discovery.Announce(c.AccessToken) if err != nil { return errors.Wrapf(errors.FromGRPCError(err), "Failed to announce this component to TTN discovery: %s", err.Error(...
[ "func", "(", "c", "*", "Component", ")", "Announce", "(", ")", "error", "{", "if", "c", ".", "Identity", ".", "ID", "==", "\"", "\"", "{", "return", "errors", ".", "NewErrInvalidArgument", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n", "...
// Announce the component to TTN discovery
[ "Announce", "the", "component", "to", "TTN", "discovery" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/discovery.go#L21-L32
22,967
TheThingsNetwork/ttn
ttnctl/util/context.go
GetID
func GetID() string { id := "ttnctl" if user, err := user.Current(); err == nil { id += "-" + user.Username } if hostname, err := os.Hostname(); err == nil { id += "@" + hostname } return id }
go
func GetID() string { id := "ttnctl" if user, err := user.Current(); err == nil { id += "-" + user.Username } if hostname, err := os.Hostname(); err == nil { id += "@" + hostname } return id }
[ "func", "GetID", "(", ")", "string", "{", "id", ":=", "\"", "\"", "\n", "if", "user", ",", "err", ":=", "user", ".", "Current", "(", ")", ";", "err", "==", "nil", "{", "id", "+=", "\"", "\"", "+", "user", ".", "Username", "\n", "}", "\n", "if...
// GetID retrns the ID of this ttnctl
[ "GetID", "retrns", "the", "ID", "of", "this", "ttnctl" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/context.go#L18-L27
22,968
TheThingsNetwork/ttn
ttnctl/util/context.go
GetContext
func GetContext(log ttnlog.Interface, extraPairs ...string) context.Context { token, err := GetTokenSource(log).Token() if err != nil { log.WithError(err).Fatal("Could not get token") } ctx := context.Background() ctx = ttnctx.OutgoingContextWithID(ctx, GetID()) ctx = ttnctx.OutgoingContextWithServiceInfo(ctx, ...
go
func GetContext(log ttnlog.Interface, extraPairs ...string) context.Context { token, err := GetTokenSource(log).Token() if err != nil { log.WithError(err).Fatal("Could not get token") } ctx := context.Background() ctx = ttnctx.OutgoingContextWithID(ctx, GetID()) ctx = ttnctx.OutgoingContextWithServiceInfo(ctx, ...
[ "func", "GetContext", "(", "log", "ttnlog", ".", "Interface", ",", "extraPairs", "...", "string", ")", "context", ".", "Context", "{", "token", ",", "err", ":=", "GetTokenSource", "(", "log", ")", ".", "Token", "(", ")", "\n", "if", "err", "!=", "nil",...
// GetContext returns a new context
[ "GetContext", "returns", "a", "new", "context" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/context.go#L30-L40
22,969
TheThingsNetwork/ttn
core/handler/application/migrate/2_0_0_add_version.go
AddVersion
func AddVersion(prefix string) storage.MigrateFunction { return func(client *redis.Client, key string, obj map[string]string) (string, map[string]string, error) { return "2.4.1", obj, nil } }
go
func AddVersion(prefix string) storage.MigrateFunction { return func(client *redis.Client, key string, obj map[string]string) (string, map[string]string, error) { return "2.4.1", obj, nil } }
[ "func", "AddVersion", "(", "prefix", "string", ")", "storage", ".", "MigrateFunction", "{", "return", "func", "(", "client", "*", "redis", ".", "Client", ",", "key", "string", ",", "obj", "map", "[", "string", "]", "string", ")", "(", "string", ",", "m...
// AddVersion migration from nothing to 2.4.1
[ "AddVersion", "migration", "from", "nothing", "to", "2", ".", "4", ".", "1" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/application/migrate/2_0_0_add_version.go#L12-L16
22,970
TheThingsNetwork/ttn
core/discovery/server.go
RegisterRPC
func (d *discovery) RegisterRPC(s *grpc.Server) { server := &discoveryServer{d} pb.RegisterDiscoveryServer(s, server) }
go
func (d *discovery) RegisterRPC(s *grpc.Server) { server := &discoveryServer{d} pb.RegisterDiscoveryServer(s, server) }
[ "func", "(", "d", "*", "discovery", ")", "RegisterRPC", "(", "s", "*", "grpc", ".", "Server", ")", "{", "server", ":=", "&", "discoveryServer", "{", "d", "}", "\n", "pb", ".", "RegisterDiscoveryServer", "(", "s", ",", "server", ")", "\n", "}" ]
// RegisterRPC registers the local discovery with a gRPC server
[ "RegisterRPC", "registers", "the", "local", "discovery", "with", "a", "gRPC", "server" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/discovery/server.go#L210-L213
22,971
TheThingsNetwork/ttn
ttnctl/util/handler.go
GetHandlerManager
func GetHandlerManager(ctx ttnlog.Interface, appID string) (*grpc.ClientConn, *handlerclient.ManagerClient) { ctx.WithField("Handler", viper.GetString("handler-id")).Info("Discovering Handler...") dscConn, client := GetDiscovery(ctx) defer dscConn.Close() handlerAnnouncement, err := client.Get(GetContext(ctx), &dis...
go
func GetHandlerManager(ctx ttnlog.Interface, appID string) (*grpc.ClientConn, *handlerclient.ManagerClient) { ctx.WithField("Handler", viper.GetString("handler-id")).Info("Discovering Handler...") dscConn, client := GetDiscovery(ctx) defer dscConn.Close() handlerAnnouncement, err := client.Get(GetContext(ctx), &dis...
[ "func", "GetHandlerManager", "(", "ctx", "ttnlog", ".", "Interface", ",", "appID", "string", ")", "(", "*", "grpc", ".", "ClientConn", ",", "*", "handlerclient", ".", "ManagerClient", ")", "{", "ctx", ".", "WithField", "(", "\"", "\"", ",", "viper", ".",...
// GetHandlerManager gets a new HandlerManager for ttnctl
[ "GetHandlerManager", "gets", "a", "new", "HandlerManager", "for", "ttnctl" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/handler.go#L17-L41
22,972
TheThingsNetwork/ttn
core/handler/cayennelpp/decoder.go
Decode
func (d *Decoder) Decode(payload []byte, fPort uint8) (map[string]interface{}, bool, error) { decoder := protocol.NewDecoder(bytes.NewBuffer(payload)) d.result = make(map[string]interface{}) if err := decoder.DecodeUplink(d); err != nil { return nil, false, err } return d.result, true, nil }
go
func (d *Decoder) Decode(payload []byte, fPort uint8) (map[string]interface{}, bool, error) { decoder := protocol.NewDecoder(bytes.NewBuffer(payload)) d.result = make(map[string]interface{}) if err := decoder.DecodeUplink(d); err != nil { return nil, false, err } return d.result, true, nil }
[ "func", "(", "d", "*", "Decoder", ")", "Decode", "(", "payload", "[", "]", "byte", ",", "fPort", "uint8", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "bool", ",", "error", ")", "{", "decoder", ":=", "protocol", ".", "NewDecoder...
// Decodes decodes the CayenneLPP payload to fields
[ "Decodes", "decodes", "the", "CayenneLPP", "payload", "to", "fields" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/cayennelpp/decoder.go#L19-L26
22,973
TheThingsNetwork/ttn
utils/pointer/pointer.go
Int8
func Int8(v int8) *int8 { p := new(int8) *p = v return p }
go
func Int8(v int8) *int8 { p := new(int8) *p = v return p }
[ "func", "Int8", "(", "v", "int8", ")", "*", "int8", "{", "p", ":=", "new", "(", "int8", ")", "\n", "*", "p", "=", "v", "\n", "return", "p", "\n", "}" ]
// Int8 creates a pointer to an int8 from an int8 value
[ "Int8", "creates", "a", "pointer", "to", "an", "int8", "from", "an", "int8", "value" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/pointer/pointer.go#L29-L33
22,974
TheThingsNetwork/ttn
utils/pointer/pointer.go
Int16
func Int16(v int16) *int16 { p := new(int16) *p = v return p }
go
func Int16(v int16) *int16 { p := new(int16) *p = v return p }
[ "func", "Int16", "(", "v", "int16", ")", "*", "int16", "{", "p", ":=", "new", "(", "int16", ")", "\n", "*", "p", "=", "v", "\n", "return", "p", "\n", "}" ]
// Int16 creates a pointer to an int16 from an int16 value
[ "Int16", "creates", "a", "pointer", "to", "an", "int16", "from", "an", "int16", "value" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/pointer/pointer.go#L36-L40
22,975
TheThingsNetwork/ttn
utils/pointer/pointer.go
Uint8
func Uint8(v uint8) *uint8 { p := new(uint8) *p = v return p }
go
func Uint8(v uint8) *uint8 { p := new(uint8) *p = v return p }
[ "func", "Uint8", "(", "v", "uint8", ")", "*", "uint8", "{", "p", ":=", "new", "(", "uint8", ")", "\n", "*", "p", "=", "v", "\n", "return", "p", "\n", "}" ]
// Uint8 creates a pointer to an unsigned int from an unsigned int8 value
[ "Uint8", "creates", "a", "pointer", "to", "an", "unsigned", "int", "from", "an", "unsigned", "int8", "value" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/pointer/pointer.go#L64-L68
22,976
TheThingsNetwork/ttn
utils/pointer/pointer.go
Uint16
func Uint16(v uint16) *uint16 { p := new(uint16) *p = v return p }
go
func Uint16(v uint16) *uint16 { p := new(uint16) *p = v return p }
[ "func", "Uint16", "(", "v", "uint16", ")", "*", "uint16", "{", "p", ":=", "new", "(", "uint16", ")", "\n", "*", "p", "=", "v", "\n", "return", "p", "\n", "}" ]
// Uint16 creates a pointer to an unsigned int from an unsigned int16 value
[ "Uint16", "creates", "a", "pointer", "to", "an", "unsigned", "int", "from", "an", "unsigned", "int16", "value" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/pointer/pointer.go#L71-L75
22,977
TheThingsNetwork/ttn
utils/pointer/pointer.go
Float32
func Float32(v float32) *float32 { p := new(float32) *p = v return p }
go
func Float32(v float32) *float32 { p := new(float32) *p = v return p }
[ "func", "Float32", "(", "v", "float32", ")", "*", "float32", "{", "p", ":=", "new", "(", "float32", ")", "\n", "*", "p", "=", "v", "\n", "return", "p", "\n", "}" ]
// Float32 creates a pointer to a float32 from a float32 value
[ "Float32", "creates", "a", "pointer", "to", "a", "float32", "from", "a", "float32", "value" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/pointer/pointer.go#L92-L96
22,978
TheThingsNetwork/ttn
utils/pointer/pointer.go
Time
func Time(v time.Time) *time.Time { p := new(time.Time) *p = v return p }
go
func Time(v time.Time) *time.Time { p := new(time.Time) *p = v return p }
[ "func", "Time", "(", "v", "time", ".", "Time", ")", "*", "time", ".", "Time", "{", "p", ":=", "new", "(", "time", ".", "Time", ")", "\n", "*", "p", "=", "v", "\n", "return", "p", "\n", "}" ]
// Time creates a pointer to a time.Time from a time.Time value
[ "Time", "creates", "a", "pointer", "to", "a", "time", ".", "Time", "from", "a", "time", ".", "Time", "value" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/pointer/pointer.go#L113-L117
22,979
TheThingsNetwork/ttn
core/handler/device/migrate/device.go
DeviceMigrations
func DeviceMigrations(prefix string) map[string]storage.MigrateFunction { funcs := make(map[string]storage.MigrateFunction) for v, f := range deviceMigrations { funcs[v] = f(prefix) } return funcs }
go
func DeviceMigrations(prefix string) map[string]storage.MigrateFunction { funcs := make(map[string]storage.MigrateFunction) for v, f := range deviceMigrations { funcs[v] = f(prefix) } return funcs }
[ "func", "DeviceMigrations", "(", "prefix", "string", ")", "map", "[", "string", "]", "storage", ".", "MigrateFunction", "{", "funcs", ":=", "make", "(", "map", "[", "string", "]", "storage", ".", "MigrateFunction", ")", "\n", "for", "v", ",", "f", ":=", ...
// DeviceMigrations filled with the prefix
[ "DeviceMigrations", "filled", "with", "the", "prefix" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/migrate/device.go#L13-L19
22,980
TheThingsNetwork/ttn
api/health/server.go
RegisterServer
func RegisterServer(s *grpc.Server) *health.Server { srv := health.NewServer() healthpb.RegisterHealthServer(s, srv) return srv }
go
func RegisterServer(s *grpc.Server) *health.Server { srv := health.NewServer() healthpb.RegisterHealthServer(s, srv) return srv }
[ "func", "RegisterServer", "(", "s", "*", "grpc", ".", "Server", ")", "*", "health", ".", "Server", "{", "srv", ":=", "health", ".", "NewServer", "(", ")", "\n", "healthpb", ".", "RegisterHealthServer", "(", "s", ",", "srv", ")", "\n", "return", "srv", ...
// RegisterServer registers and returns a new Health server
[ "RegisterServer", "registers", "and", "returns", "a", "new", "Health", "server" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/api/health/server.go#L13-L17
22,981
TheThingsNetwork/ttn
mqtt/tls.go
NewTLSClient
func NewTLSClient(ctx log.Interface, id, username, password string, tlsConfig *tls.Config, brokers ...string) Client { ttnClient := NewClient(ctx, id, username, password, brokers...).(*DefaultClient) if tlsConfig == nil { ttnClient.opts.SetTLSConfig(&tls.Config{ RootCAs: RootCAs, }) } else { ttnClient.opts....
go
func NewTLSClient(ctx log.Interface, id, username, password string, tlsConfig *tls.Config, brokers ...string) Client { ttnClient := NewClient(ctx, id, username, password, brokers...).(*DefaultClient) if tlsConfig == nil { ttnClient.opts.SetTLSConfig(&tls.Config{ RootCAs: RootCAs, }) } else { ttnClient.opts....
[ "func", "NewTLSClient", "(", "ctx", "log", ".", "Interface", ",", "id", ",", "username", ",", "password", "string", ",", "tlsConfig", "*", "tls", ".", "Config", ",", "brokers", "...", "string", ")", "Client", "{", "ttnClient", ":=", "NewClient", "(", "ct...
// NewTLSClient creates a new DefaultClient with TLS enabled
[ "NewTLSClient", "creates", "a", "new", "DefaultClient", "with", "TLS", "enabled" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/mqtt/tls.go#L16-L27
22,982
TheThingsNetwork/ttn
core/handler/application/migrate/2_4_1_payload_format.go
AddPayloadFormat
func AddPayloadFormat(prefix string) storage.MigrateFunction { return func(client *redis.Client, key string, obj map[string]string) (string, map[string]string, error) { usesCustom := false if decoder, ok := obj["decoder"]; ok { delete(obj, "decoder") obj["custom_decoder"] = decoder usesCustom = true } ...
go
func AddPayloadFormat(prefix string) storage.MigrateFunction { return func(client *redis.Client, key string, obj map[string]string) (string, map[string]string, error) { usesCustom := false if decoder, ok := obj["decoder"]; ok { delete(obj, "decoder") obj["custom_decoder"] = decoder usesCustom = true } ...
[ "func", "AddPayloadFormat", "(", "prefix", "string", ")", "storage", ".", "MigrateFunction", "{", "return", "func", "(", "client", "*", "redis", ".", "Client", ",", "key", "string", ",", "obj", "map", "[", "string", "]", "string", ")", "(", "string", ","...
// AddPayloadFormat migration from 2.4.1 to 2.6.1
[ "AddPayloadFormat", "migration", "from", "2", ".", "4", ".", "1", "to", "2", ".", "6", ".", "1" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/application/migrate/2_4_1_payload_format.go#L12-L40
22,983
TheThingsNetwork/ttn
core/handler/handler.go
NewRedisHandler
func NewRedisHandler(client *redis.Client, ttnBrokerID string) Handler { return &handler{ devices: device.NewRedisDeviceStore(client, "handler"), applications: application.NewRedisApplicationStore(client, "handler"), ttnBrokerID: ttnBrokerID, qUp: make(chan *types.UplinkMessage), qEvent: ...
go
func NewRedisHandler(client *redis.Client, ttnBrokerID string) Handler { return &handler{ devices: device.NewRedisDeviceStore(client, "handler"), applications: application.NewRedisApplicationStore(client, "handler"), ttnBrokerID: ttnBrokerID, qUp: make(chan *types.UplinkMessage), qEvent: ...
[ "func", "NewRedisHandler", "(", "client", "*", "redis", ".", "Client", ",", "ttnBrokerID", "string", ")", "Handler", "{", "return", "&", "handler", "{", "devices", ":", "device", ".", "NewRedisDeviceStore", "(", "client", ",", "\"", "\"", ")", ",", "applic...
// NewRedisHandler creates a new Redis-backed Handler
[ "NewRedisHandler", "creates", "a", "new", "Redis", "-", "backed", "Handler" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/handler.go#L41-L49
22,984
TheThingsNetwork/ttn
core/handler/device/converter.go
ToPb
func (d Device) ToPb() *pb_handler.Device { return &pb_handler.Device{ AppID: d.AppID, DevID: d.DevID, Description: d.Description, Device: &pb_handler.Device_LoRaWANDevice{LoRaWANDevice: d.ToLoRaWANPb()}, Latitude: d.Latitude, Longitude: d.Longitude, Altitude: d.Altitude, Attri...
go
func (d Device) ToPb() *pb_handler.Device { return &pb_handler.Device{ AppID: d.AppID, DevID: d.DevID, Description: d.Description, Device: &pb_handler.Device_LoRaWANDevice{LoRaWANDevice: d.ToLoRaWANPb()}, Latitude: d.Latitude, Longitude: d.Longitude, Altitude: d.Altitude, Attri...
[ "func", "(", "d", "Device", ")", "ToPb", "(", ")", "*", "pb_handler", ".", "Device", "{", "return", "&", "pb_handler", ".", "Device", "{", "AppID", ":", "d", ".", "AppID", ",", "DevID", ":", "d", ".", "DevID", ",", "Description", ":", "d", ".", "...
// ToPb converts a device struct to its protocol buffer
[ "ToPb", "converts", "a", "device", "struct", "to", "its", "protocol", "buffer" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L13-L24
22,985
TheThingsNetwork/ttn
core/handler/device/converter.go
ToLoRaWANPb
func (d Device) ToLoRaWANPb() *pb_lorawan.Device { pbDev := &pb_lorawan.Device{ AppID: d.AppID, AppEUI: d.AppEUI, DevID: d.DevID, DevEUI: d.DevEUI, DevAddr: &d.DevAddr, NwkSKey: &d.NwkSKey, AppSKey: &d...
go
func (d Device) ToLoRaWANPb() *pb_lorawan.Device { pbDev := &pb_lorawan.Device{ AppID: d.AppID, AppEUI: d.AppEUI, DevID: d.DevID, DevEUI: d.DevEUI, DevAddr: &d.DevAddr, NwkSKey: &d.NwkSKey, AppSKey: &d...
[ "func", "(", "d", "Device", ")", "ToLoRaWANPb", "(", ")", "*", "pb_lorawan", ".", "Device", "{", "pbDev", ":=", "&", "pb_lorawan", ".", "Device", "{", "AppID", ":", "d", ".", "AppID", ",", "AppEUI", ":", "d", ".", "AppEUI", ",", "DevID", ":", "d", ...
// ToLoRaWANPb converts a device struct to a LoRaWAN protocol buffer
[ "ToLoRaWANPb", "converts", "a", "device", "struct", "to", "a", "LoRaWAN", "protocol", "buffer" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L27-L48
22,986
TheThingsNetwork/ttn
core/handler/device/converter.go
FromPb
func FromPb(in *pb_handler.Device) *Device { d := new(Device) d.FromPb(in) return d }
go
func FromPb(in *pb_handler.Device) *Device { d := new(Device) d.FromPb(in) return d }
[ "func", "FromPb", "(", "in", "*", "pb_handler", ".", "Device", ")", "*", "Device", "{", "d", ":=", "new", "(", "Device", ")", "\n", "d", ".", "FromPb", "(", "in", ")", "\n", "return", "d", "\n", "}" ]
// FromPb returns a new device from the given proto
[ "FromPb", "returns", "a", "new", "device", "from", "the", "given", "proto" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L51-L55
22,987
TheThingsNetwork/ttn
core/handler/device/converter.go
FromPb
func (d *Device) FromPb(in *pb_handler.Device) { d.AppID = in.AppID d.DevID = in.DevID d.Description = in.Description d.Latitude = in.Latitude d.Longitude = in.Longitude d.Altitude = in.Altitude d.Attributes = in.Attributes d.FromLoRaWANPb(in.GetLoRaWANDevice()) }
go
func (d *Device) FromPb(in *pb_handler.Device) { d.AppID = in.AppID d.DevID = in.DevID d.Description = in.Description d.Latitude = in.Latitude d.Longitude = in.Longitude d.Altitude = in.Altitude d.Attributes = in.Attributes d.FromLoRaWANPb(in.GetLoRaWANDevice()) }
[ "func", "(", "d", "*", "Device", ")", "FromPb", "(", "in", "*", "pb_handler", ".", "Device", ")", "{", "d", ".", "AppID", "=", "in", ".", "AppID", "\n", "d", ".", "DevID", "=", "in", ".", "DevID", "\n", "d", ".", "Description", "=", "in", ".", ...
// FromPb fills Device fields from a device proto
[ "FromPb", "fills", "Device", "fields", "from", "a", "device", "proto" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L58-L67
22,988
TheThingsNetwork/ttn
core/handler/device/converter.go
FromLoRaWANPb
func (d *Device) FromLoRaWANPb(lorawan *pb_lorawan.Device) { if lorawan == nil { return } d.AppEUI = lorawan.AppEUI d.DevEUI = lorawan.DevEUI if lorawan.DevAddr != nil { d.DevAddr = *lorawan.DevAddr } if lorawan.AppKey != nil { d.AppKey = *lorawan.AppKey } if lorawan.AppSKey != nil { d.AppSKey = *loraw...
go
func (d *Device) FromLoRaWANPb(lorawan *pb_lorawan.Device) { if lorawan == nil { return } d.AppEUI = lorawan.AppEUI d.DevEUI = lorawan.DevEUI if lorawan.DevAddr != nil { d.DevAddr = *lorawan.DevAddr } if lorawan.AppKey != nil { d.AppKey = *lorawan.AppKey } if lorawan.AppSKey != nil { d.AppSKey = *loraw...
[ "func", "(", "d", "*", "Device", ")", "FromLoRaWANPb", "(", "lorawan", "*", "pb_lorawan", ".", "Device", ")", "{", "if", "lorawan", "==", "nil", "{", "return", "\n", "}", "\n", "d", ".", "AppEUI", "=", "lorawan", ".", "AppEUI", "\n", "d", ".", "Dev...
// FromLoRaWANPb fills Device fields from a lorawan device proto
[ "FromLoRaWANPb", "fills", "Device", "fields", "from", "a", "lorawan", "device", "proto" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/device/converter.go#L70-L106
22,989
TheThingsNetwork/ttn
ttnctl/util/cli_input.go
ReadInput
func ReadInput(reader *bufio.Reader) (string, error) { input, err := reader.ReadString('\n') if err != nil { return "", err } return strings.TrimRight(input, "\n"), nil }
go
func ReadInput(reader *bufio.Reader) (string, error) { input, err := reader.ReadString('\n') if err != nil { return "", err } return strings.TrimRight(input, "\n"), nil }
[ "func", "ReadInput", "(", "reader", "*", "bufio", ".", "Reader", ")", "(", "string", ",", "error", ")", "{", "input", ",", "err", ":=", "reader", ".", "ReadString", "(", "'\\n'", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", ...
// ReadInput allows to read an input line from the user
[ "ReadInput", "allows", "to", "read", "an", "input", "line", "from", "the", "user" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/ttnctl/util/cli_input.go#L106-L112
22,990
TheThingsNetwork/ttn
utils/security/load_keys.go
LoadKeypair
func LoadKeypair(location string) (*ecdsa.PrivateKey, error) { priv, err := ioutil.ReadFile(filepath.Clean(location + "/server.key")) if err != nil { return nil, err } privBlock, _ := pem.Decode(priv) if privBlock == nil { return nil, errors.New("No private key data found") } privKey, err := x509.ParseECPriv...
go
func LoadKeypair(location string) (*ecdsa.PrivateKey, error) { priv, err := ioutil.ReadFile(filepath.Clean(location + "/server.key")) if err != nil { return nil, err } privBlock, _ := pem.Decode(priv) if privBlock == nil { return nil, errors.New("No private key data found") } privKey, err := x509.ParseECPriv...
[ "func", "LoadKeypair", "(", "location", "string", ")", "(", "*", "ecdsa", ".", "PrivateKey", ",", "error", ")", "{", "priv", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filepath", ".", "Clean", "(", "location", "+", "\"", "\"", ")", ")", "\n",...
// LoadKeypair loads the keypair in the given location
[ "LoadKeypair", "loads", "the", "keypair", "in", "the", "given", "location" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/load_keys.go#L16-L30
22,991
TheThingsNetwork/ttn
utils/security/load_keys.go
LoadCert
func LoadCert(location string) (cert []byte, err error) { cert, err = ioutil.ReadFile(filepath.Clean(location + "/server.cert")) if err != nil { return } return }
go
func LoadCert(location string) (cert []byte, err error) { cert, err = ioutil.ReadFile(filepath.Clean(location + "/server.cert")) if err != nil { return } return }
[ "func", "LoadCert", "(", "location", "string", ")", "(", "cert", "[", "]", "byte", ",", "err", "error", ")", "{", "cert", ",", "err", "=", "ioutil", ".", "ReadFile", "(", "filepath", ".", "Clean", "(", "location", "+", "\"", "\"", ")", ")", "\n", ...
// LoadCert loads the certificate in the given location
[ "LoadCert", "loads", "the", "certificate", "in", "the", "given", "location" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/security/load_keys.go#L33-L39
22,992
TheThingsNetwork/ttn
core/handler/cayennelpp/encoder.go
Encode
func (e *Encoder) Encode(fields map[string]interface{}, fPort uint8) ([]byte, bool, error) { encoder := protocol.NewEncoder() for name, value := range fields { key, channel, err := parseName(name) if err != nil { continue } switch key { case valueKey: if val, ok := value.(float64); ok { encoder.Ad...
go
func (e *Encoder) Encode(fields map[string]interface{}, fPort uint8) ([]byte, bool, error) { encoder := protocol.NewEncoder() for name, value := range fields { key, channel, err := parseName(name) if err != nil { continue } switch key { case valueKey: if val, ok := value.(float64); ok { encoder.Ad...
[ "func", "(", "e", "*", "Encoder", ")", "Encode", "(", "fields", "map", "[", "string", "]", "interface", "{", "}", ",", "fPort", "uint8", ")", "(", "[", "]", "byte", ",", "bool", ",", "error", ")", "{", "encoder", ":=", "protocol", ".", "NewEncoder"...
// Encode encodes the fields to CayenneLPP
[ "Encode", "encodes", "the", "fields", "to", "CayenneLPP" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/handler/cayennelpp/encoder.go#L16-L31
22,993
TheThingsNetwork/ttn
core/types/json_time.go
BuildTime
func BuildTime(unixNano int64) JSONTime { if unixNano == 0 { return JSONTime{} } return JSONTime(time.Unix(0, 0).Add(time.Duration(unixNano)).UTC()) }
go
func BuildTime(unixNano int64) JSONTime { if unixNano == 0 { return JSONTime{} } return JSONTime(time.Unix(0, 0).Add(time.Duration(unixNano)).UTC()) }
[ "func", "BuildTime", "(", "unixNano", "int64", ")", "JSONTime", "{", "if", "unixNano", "==", "0", "{", "return", "JSONTime", "{", "}", "\n", "}", "\n", "return", "JSONTime", "(", "time", ".", "Unix", "(", "0", ",", "0", ")", ".", "Add", "(", "time"...
// BuildTime builds a new JSONTime
[ "BuildTime", "builds", "a", "new", "JSONTime" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/types/json_time.go#L35-L40
22,994
TheThingsNetwork/ttn
core/router/gateway/schedule.go
NewSchedule
func NewSchedule(ctx ttnlog.Interface) Schedule { s := &schedule{ ctx: ctx, items: make(map[string]*scheduledItem), downlinkSubscriptions: make(map[string]chan *router_pb.DownlinkMessage), } go func() { for { <-time.After(10 * time.Second) s.RLock() numItems := len(...
go
func NewSchedule(ctx ttnlog.Interface) Schedule { s := &schedule{ ctx: ctx, items: make(map[string]*scheduledItem), downlinkSubscriptions: make(map[string]chan *router_pb.DownlinkMessage), } go func() { for { <-time.After(10 * time.Second) s.RLock() numItems := len(...
[ "func", "NewSchedule", "(", "ctx", "ttnlog", ".", "Interface", ")", "Schedule", "{", "s", ":=", "&", "schedule", "{", "ctx", ":", "ctx", ",", "items", ":", "make", "(", "map", "[", "string", "]", "*", "scheduledItem", ")", ",", "downlinkSubscriptions", ...
// NewSchedule creates a new Schedule
[ "NewSchedule", "creates", "a", "new", "Schedule" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/gateway/schedule.go#L39-L64
22,995
TheThingsNetwork/ttn
core/router/gateway/schedule.go
getConflicts
func (s *schedule) getConflicts(timestamp uint32, length uint32) (conflicts uint) { s.RLock() defer s.RUnlock() for _, item := range s.items { scheduledFrom := uint64(item.timestamp) % uintmax scheduledTo := scheduledFrom + uint64(item.length) from := uint64(timestamp) to := from + uint64(length) if sched...
go
func (s *schedule) getConflicts(timestamp uint32, length uint32) (conflicts uint) { s.RLock() defer s.RUnlock() for _, item := range s.items { scheduledFrom := uint64(item.timestamp) % uintmax scheduledTo := scheduledFrom + uint64(item.length) from := uint64(timestamp) to := from + uint64(length) if sched...
[ "func", "(", "s", "*", "schedule", ")", "getConflicts", "(", "timestamp", "uint32", ",", "length", "uint32", ")", "(", "conflicts", "uint", ")", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "for", "_", ",", ...
// getConflicts walks over the schedule and returns the number of conflicts. // Both timestamp and length are in microseconds
[ "getConflicts", "walks", "over", "the", "schedule", "and", "returns", "the", "number", "of", "conflicts", ".", "Both", "timestamp", "and", "length", "are", "in", "microseconds" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/router/gateway/schedule.go#L104-L128
22,996
TheThingsNetwork/ttn
utils/docs/generate.go
Generate
func Generate(cmd *cobra.Command) string { buf := new(bytes.Buffer) cmds := genCmdList(cmd) sort.Sort(byName(cmds)) for _, cmd := range cmds { if len(strings.Split(cmd.CommandPath(), " ")) == 1 { fmt.Fprint(buf, "**Options**\n\n") printOptions(buf, cmd) fmt.Fprintln(buf) continue } depth := len(...
go
func Generate(cmd *cobra.Command) string { buf := new(bytes.Buffer) cmds := genCmdList(cmd) sort.Sort(byName(cmds)) for _, cmd := range cmds { if len(strings.Split(cmd.CommandPath(), " ")) == 1 { fmt.Fprint(buf, "**Options**\n\n") printOptions(buf, cmd) fmt.Fprintln(buf) continue } depth := len(...
[ "func", "Generate", "(", "cmd", "*", "cobra", ".", "Command", ")", "string", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n\n", "cmds", ":=", "genCmdList", "(", "cmd", ")", "\n", "sort", ".", "Sort", "(", "byName", "(", "cmds", ")",...
// Generate prints API docs for a command
[ "Generate", "prints", "API", "docs", "for", "a", "command" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/utils/docs/generate.go#L23-L58
22,997
TheThingsNetwork/ttn
amqp/downlink.go
PublishDownlink
func (c *DefaultPublisher) PublishDownlink(dataDown types.DownlinkMessage) error { key := DeviceKey{dataDown.AppID, dataDown.DevID, DeviceDownlink, ""} msg, err := json.Marshal(dataDown) if err != nil { return fmt.Errorf("Unable to marshal the message payload: %s", err) } return c.publish(key.String(), msg, time...
go
func (c *DefaultPublisher) PublishDownlink(dataDown types.DownlinkMessage) error { key := DeviceKey{dataDown.AppID, dataDown.DevID, DeviceDownlink, ""} msg, err := json.Marshal(dataDown) if err != nil { return fmt.Errorf("Unable to marshal the message payload: %s", err) } return c.publish(key.String(), msg, time...
[ "func", "(", "c", "*", "DefaultPublisher", ")", "PublishDownlink", "(", "dataDown", "types", ".", "DownlinkMessage", ")", "error", "{", "key", ":=", "DeviceKey", "{", "dataDown", ".", "AppID", ",", "dataDown", ".", "DevID", ",", "DeviceDownlink", ",", "\"", ...
// PublishDownlink publishes a downlink message to the AMQP broker
[ "PublishDownlink", "publishes", "a", "downlink", "message", "to", "the", "AMQP", "broker" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/amqp/downlink.go#L18-L25
22,998
TheThingsNetwork/ttn
core/component/auth.go
InitAuth
func (c *Component) InitAuth() error { inits := []func() error{ c.initAuthServers, c.initKeyPair, c.initRoots, c.initBgCtx, } if c.Config.UseTLS { inits = append(inits, c.initTLS) } for _, init := range inits { if err := init(); err != nil { return err } } return nil }
go
func (c *Component) InitAuth() error { inits := []func() error{ c.initAuthServers, c.initKeyPair, c.initRoots, c.initBgCtx, } if c.Config.UseTLS { inits = append(inits, c.initTLS) } for _, init := range inits { if err := init(); err != nil { return err } } return nil }
[ "func", "(", "c", "*", "Component", ")", "InitAuth", "(", ")", "error", "{", "inits", ":=", "[", "]", "func", "(", ")", "error", "{", "c", ".", "initAuthServers", ",", "c", ".", "initKeyPair", ",", "c", ".", "initRoots", ",", "c", ".", "initBgCtx",...
// InitAuth initializes Auth functionality
[ "InitAuth", "initializes", "Auth", "functionality" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L33-L51
22,999
TheThingsNetwork/ttn
core/component/auth.go
UpdateTokenKey
func (c *Component) UpdateTokenKey() error { if c.TokenKeyProvider == nil { return errors.NewErrInternal("No public key provider configured for token validation") } // Set up Auth Server Token Validation err := c.TokenKeyProvider.Update() if err != nil { c.Ctx.Warnf("ttn: Failed to refresh public keys for tok...
go
func (c *Component) UpdateTokenKey() error { if c.TokenKeyProvider == nil { return errors.NewErrInternal("No public key provider configured for token validation") } // Set up Auth Server Token Validation err := c.TokenKeyProvider.Update() if err != nil { c.Ctx.Warnf("ttn: Failed to refresh public keys for tok...
[ "func", "(", "c", "*", "Component", ")", "UpdateTokenKey", "(", ")", "error", "{", "if", "c", ".", "TokenKeyProvider", "==", "nil", "{", "return", "errors", ".", "NewErrInternal", "(", "\"", "\"", ")", "\n", "}", "\n\n", "// Set up Auth Server Token Validati...
// UpdateTokenKey updates the OAuth Bearer token key
[ "UpdateTokenKey", "updates", "the", "OAuth", "Bearer", "token", "key" ]
fc5709a55c20e1712047e5cb5a8d571aa62eefbb
https://github.com/TheThingsNetwork/ttn/blob/fc5709a55c20e1712047e5cb5a8d571aa62eefbb/core/component/auth.go#L107-L121