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,200
libopenstorage/openstorage
osdconfig/api.go
EnumerateNodeConf
func (manager *configManager) EnumerateNodeConf() (*NodesConfig, error) { keys, err := manager.kv.Keys(filepath.Join(baseKey, nodeKey), "/") if err != nil { return nil, fmt.Errorf("kvdb.Keys() returned error: " + err.Error()) } nodesConfig := new(NodesConfig) *nodesConfig = make([]*NodeConfig, len(keys)) for i...
go
func (manager *configManager) EnumerateNodeConf() (*NodesConfig, error) { keys, err := manager.kv.Keys(filepath.Join(baseKey, nodeKey), "/") if err != nil { return nil, fmt.Errorf("kvdb.Keys() returned error: " + err.Error()) } nodesConfig := new(NodesConfig) *nodesConfig = make([]*NodeConfig, len(keys)) for i...
[ "func", "(", "manager", "*", "configManager", ")", "EnumerateNodeConf", "(", ")", "(", "*", "NodesConfig", ",", "error", ")", "{", "keys", ",", "err", ":=", "manager", ".", "kv", ".", "Keys", "(", "filepath", ".", "Join", "(", "baseKey", ",", "nodeKey"...
// EnumerateNodeConf fetches data for all nodes
[ "EnumerateNodeConf", "fetches", "data", "for", "all", "nodes" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L101-L119
22,201
libopenstorage/openstorage
osdconfig/api.go
WatchCluster
func (manager *configManager) WatchCluster(name string, cb func(config *ClusterConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbCluster[name]; present { return fmt.Errorf("%s already present", name) } manager.cbCluster[name] = cb return nil }
go
func (manager *configManager) WatchCluster(name string, cb func(config *ClusterConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbCluster[name]; present { return fmt.Errorf("%s already present", name) } manager.cbCluster[name] = cb return nil }
[ "func", "(", "manager", "*", "configManager", ")", "WatchCluster", "(", "name", "string", ",", "cb", "func", "(", "config", "*", "ClusterConfig", ")", "error", ")", "error", "{", "manager", ".", "Lock", "(", ")", "\n", "defer", "manager", ".", "Unlock", ...
// WatchCluster registers user defined function as callback and sets a watch for changes // to cluster configuration
[ "WatchCluster", "registers", "user", "defined", "function", "as", "callback", "and", "sets", "a", "watch", "for", "changes", "to", "cluster", "configuration" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L123-L132
22,202
libopenstorage/openstorage
osdconfig/api.go
WatchNode
func (manager *configManager) WatchNode(name string, cb func(config *NodeConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbNode[name]; present { return fmt.Errorf("%s already present", name) } manager.cbNode[name] = cb return nil }
go
func (manager *configManager) WatchNode(name string, cb func(config *NodeConfig) error) error { manager.Lock() defer manager.Unlock() if _, present := manager.cbNode[name]; present { return fmt.Errorf("%s already present", name) } manager.cbNode[name] = cb return nil }
[ "func", "(", "manager", "*", "configManager", ")", "WatchNode", "(", "name", "string", ",", "cb", "func", "(", "config", "*", "NodeConfig", ")", "error", ")", "error", "{", "manager", ".", "Lock", "(", ")", "\n", "defer", "manager", ".", "Unlock", "(",...
// WatchNode registers user defined function as callback and sets a watch for changes // to node configuration
[ "WatchNode", "registers", "user", "defined", "function", "as", "callback", "and", "sets", "a", "watch", "for", "changes", "to", "node", "configuration" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/osdconfig/api.go#L136-L145
22,203
libopenstorage/openstorage
pkg/mount/mount.go
Mount
func (m *DefaultMounter) Mount( source string, target string, fstype string, flags uintptr, data string, timeout int, ) error { return syscall.Mount(source, target, fstype, flags, data) }
go
func (m *DefaultMounter) Mount( source string, target string, fstype string, flags uintptr, data string, timeout int, ) error { return syscall.Mount(source, target, fstype, flags, data) }
[ "func", "(", "m", "*", "DefaultMounter", ")", "Mount", "(", "source", "string", ",", "target", "string", ",", "fstype", "string", ",", "flags", "uintptr", ",", "data", "string", ",", "timeout", "int", ",", ")", "error", "{", "return", "syscall", ".", "...
// Mount default mount implementation is syscall.
[ "Mount", "default", "mount", "implementation", "is", "syscall", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L157-L166
22,204
libopenstorage/openstorage
pkg/mount/mount.go
Unmount
func (m *DefaultMounter) Unmount(target string, flags int, timeout int) error { return syscall.Unmount(target, flags) }
go
func (m *DefaultMounter) Unmount(target string, flags int, timeout int) error { return syscall.Unmount(target, flags) }
[ "func", "(", "m", "*", "DefaultMounter", ")", "Unmount", "(", "target", "string", ",", "flags", "int", ",", "timeout", "int", ")", "error", "{", "return", "syscall", ".", "Unmount", "(", "target", ",", "flags", ")", "\n", "}" ]
// Unmount default unmount implementation is syscall.
[ "Unmount", "default", "unmount", "implementation", "is", "syscall", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L169-L171
22,205
libopenstorage/openstorage
pkg/mount/mount.go
String
func (m *Mounter) String() string { s := struct { mounts DeviceMap paths PathMap allowedDirs []string trashLocation string }{ mounts: m.mounts, paths: m.paths, allowedDirs: m.allowedDirs, trashLocation: m.trashLocation, } return fmt.Sprintf("%#v", s) }
go
func (m *Mounter) String() string { s := struct { mounts DeviceMap paths PathMap allowedDirs []string trashLocation string }{ mounts: m.mounts, paths: m.paths, allowedDirs: m.allowedDirs, trashLocation: m.trashLocation, } return fmt.Sprintf("%#v", s) }
[ "func", "(", "m", "*", "Mounter", ")", "String", "(", ")", "string", "{", "s", ":=", "struct", "{", "mounts", "DeviceMap", "\n", "paths", "PathMap", "\n", "allowedDirs", "[", "]", "string", "\n", "trashLocation", "string", "\n", "}", "{", "mounts", ":"...
// String representation of Mounter
[ "String", "representation", "of", "Mounter" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L174-L188
22,206
libopenstorage/openstorage
pkg/mount/mount.go
Inspect
func (m *Mounter) Inspect(sourcePath string) []*PathInfo { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } return v.Mountpoint }
go
func (m *Mounter) Inspect(sourcePath string) []*PathInfo { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } return v.Mountpoint }
[ "func", "(", "m", "*", "Mounter", ")", "Inspect", "(", "sourcePath", "string", ")", "[", "]", "*", "PathInfo", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":=", "m", ".", "mounts", "[", ...
// Inspect mount table for device
[ "Inspect", "mount", "table", "for", "device" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L191-L200
22,207
libopenstorage/openstorage
pkg/mount/mount.go
Mounts
func (m *Mounter) Mounts(sourcePath string) []string { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } mounts := make([]string, len(v.Mountpoint)) for i, v := range v.Mountpoint { mounts[i] = v.Path } return mounts }
go
func (m *Mounter) Mounts(sourcePath string) []string { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return nil } mounts := make([]string, len(v.Mountpoint)) for i, v := range v.Mountpoint { mounts[i] = v.Path } return mounts }
[ "func", "(", "m", "*", "Mounter", ")", "Mounts", "(", "sourcePath", "string", ")", "[", "]", "string", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":=", "m", ".", "mounts", "[", "sourceP...
// Mounts returns mount table for device
[ "Mounts", "returns", "mount", "table", "for", "device" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L203-L218
22,208
libopenstorage/openstorage
pkg/mount/mount.go
GetSourcePaths
func (m *Mounter) GetSourcePaths() []string { m.Lock() defer m.Unlock() sourcePaths := make([]string, len(m.mounts)) i := 0 for path := range m.mounts { sourcePaths[i] = path i++ } return sourcePaths }
go
func (m *Mounter) GetSourcePaths() []string { m.Lock() defer m.Unlock() sourcePaths := make([]string, len(m.mounts)) i := 0 for path := range m.mounts { sourcePaths[i] = path i++ } return sourcePaths }
[ "func", "(", "m", "*", "Mounter", ")", "GetSourcePaths", "(", ")", "[", "]", "string", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "sourcePaths", ":=", "make", "(", "[", "]", "string", ",", "len", "(", ...
// GetSourcePaths returns all source paths from the mount table
[ "GetSourcePaths", "returns", "all", "source", "paths", "from", "the", "mount", "table" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L221-L232
22,209
libopenstorage/openstorage
pkg/mount/mount.go
HasMounts
func (m *Mounter) HasMounts(sourcePath string) int { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return 0 } return len(v.Mountpoint) }
go
func (m *Mounter) HasMounts(sourcePath string) int { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return 0 } return len(v.Mountpoint) }
[ "func", "(", "m", "*", "Mounter", ")", "HasMounts", "(", "sourcePath", "string", ")", "int", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":=", "m", ".", "mounts", "[", "sourcePath", "]", ...
// HasMounts determines returns the number of mounts for the device.
[ "HasMounts", "determines", "returns", "the", "number", "of", "mounts", "for", "the", "device", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L235-L244
22,210
libopenstorage/openstorage
pkg/mount/mount.go
Exists
func (m *Mounter) Exists(sourcePath string, path string) (bool, error) { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return false, ErrEnoent } for _, p := range v.Mountpoint { if p.Path == path { return true, nil } } return false, nil }
go
func (m *Mounter) Exists(sourcePath string, path string) (bool, error) { m.Lock() defer m.Unlock() v, ok := m.mounts[sourcePath] if !ok { return false, ErrEnoent } for _, p := range v.Mountpoint { if p.Path == path { return true, nil } } return false, nil }
[ "func", "(", "m", "*", "Mounter", ")", "Exists", "(", "sourcePath", "string", ",", "path", "string", ")", "(", "bool", ",", "error", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "v", ",", "ok", ":="...
// Exists scans mountpaths for specified device and returns true if path is one of the // mountpaths. ErrEnoent may be retuned if the device is not found
[ "Exists", "scans", "mountpaths", "for", "specified", "device", "and", "returns", "true", "if", "path", "is", "one", "of", "the", "mountpaths", ".", "ErrEnoent", "may", "be", "retuned", "if", "the", "device", "is", "not", "found" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L263-L277
22,211
libopenstorage/openstorage
pkg/mount/mount.go
GetRootPath
func (m *Mounter) GetRootPath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for _, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return p.Root, nil } } } return "", ErrEnoent }
go
func (m *Mounter) GetRootPath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for _, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return p.Root, nil } } } return "", ErrEnoent }
[ "func", "(", "m", "*", "Mounter", ")", "GetRootPath", "(", "mountPath", "string", ")", "(", "string", ",", "error", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "v", ":=", "range", ...
// GetRootPath scans mounts for a specified mountPath and return the // rootPath if found or returns an ErrEnoent
[ "GetRootPath", "scans", "mounts", "for", "a", "specified", "mountPath", "and", "return", "the", "rootPath", "if", "found", "or", "returns", "an", "ErrEnoent" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L281-L293
22,212
libopenstorage/openstorage
pkg/mount/mount.go
GetSourcePath
func (m *Mounter) GetSourcePath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for k, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return k, nil } } } return "", ErrEnoent }
go
func (m *Mounter) GetSourcePath(mountPath string) (string, error) { m.Lock() defer m.Unlock() for k, v := range m.mounts { for _, p := range v.Mountpoint { if p.Path == mountPath { return k, nil } } } return "", ErrEnoent }
[ "func", "(", "m", "*", "Mounter", ")", "GetSourcePath", "(", "mountPath", "string", ")", "(", "string", ",", "error", ")", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "for", "k", ",", "v", ":=", "range", ...
// GetSourcePath scans mount for a specified mountPath and returns the sourcePath // if found or returnes an ErrEnoent
[ "GetSourcePath", "scans", "mount", "for", "a", "specified", "mountPath", "and", "returns", "the", "sourcePath", "if", "found", "or", "returnes", "an", "ErrEnoent" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L297-L309
22,213
libopenstorage/openstorage
pkg/mount/mount.go
reload
func (m *Mounter) reload(device string, newM *Info) error { m.Lock() defer m.Unlock() // New mountable has no mounts, delete old mounts. if newM == nil { delete(m.mounts, device) return nil } // Old mountable had no mounts, copy over new mounts. oldM, ok := m.mounts[device] if !ok { m.mounts[device] = n...
go
func (m *Mounter) reload(device string, newM *Info) error { m.Lock() defer m.Unlock() // New mountable has no mounts, delete old mounts. if newM == nil { delete(m.mounts, device) return nil } // Old mountable had no mounts, copy over new mounts. oldM, ok := m.mounts[device] if !ok { m.mounts[device] = n...
[ "func", "(", "m", "*", "Mounter", ")", "reload", "(", "device", "string", ",", "newM", "*", "Info", ")", "error", "{", "m", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "Unlock", "(", ")", "\n\n", "// New mountable has no mounts, delete old mounts.", ...
// reload from newM
[ "reload", "from", "newM" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L330-L360
22,214
libopenstorage/openstorage
pkg/mount/mount.go
Unmount
func (m *Mounter) Unmount( devPath string, path string, flags int, timeout int, opts map[string]string, ) error { m.Lock() // device gets overwritten if opts specifies fuse mount with // options.OptionsDeviceFuseMount. device := devPath path = normalizeMountPath(path) if value, ok := opts[options.OptionsDevi...
go
func (m *Mounter) Unmount( devPath string, path string, flags int, timeout int, opts map[string]string, ) error { m.Lock() // device gets overwritten if opts specifies fuse mount with // options.OptionsDeviceFuseMount. device := devPath path = normalizeMountPath(path) if value, ok := opts[options.OptionsDevi...
[ "func", "(", "m", "*", "Mounter", ")", "Unmount", "(", "devPath", "string", ",", "path", "string", ",", "flags", "int", ",", "timeout", "int", ",", "opts", "map", "[", "string", "]", "string", ",", ")", "error", "{", "m", ".", "Lock", "(", ")", "...
// Unmount device at mountpoint and from the matrix. // ErrEnoent is returned if the device or mountpoint for the device is not found.
[ "Unmount", "device", "at", "mountpoint", "and", "from", "the", "matrix", ".", "ErrEnoent", "is", "returned", "if", "the", "device", "or", "mountpoint", "for", "the", "device", "is", "not", "found", "." ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L589-L635
22,215
libopenstorage/openstorage
pkg/mount/mount.go
RemoveMountPath
func (m *Mounter) RemoveMountPath(mountPath string, opts map[string]string) error { if _, err := os.Stat(mountPath); err == nil { if options.IsBoolOptionSet(opts, options.OptionsWaitBeforeDelete) { hasher := md5.New() hasher.Write([]byte(mountPath)) symlinkName := hex.EncodeToString(hasher.Sum(nil)) syml...
go
func (m *Mounter) RemoveMountPath(mountPath string, opts map[string]string) error { if _, err := os.Stat(mountPath); err == nil { if options.IsBoolOptionSet(opts, options.OptionsWaitBeforeDelete) { hasher := md5.New() hasher.Write([]byte(mountPath)) symlinkName := hex.EncodeToString(hasher.Sum(nil)) syml...
[ "func", "(", "m", "*", "Mounter", ")", "RemoveMountPath", "(", "mountPath", "string", ",", "opts", "map", "[", "string", "]", "string", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "mountPath", ")", ";", "err", "==", "nil...
// RemoveMountPath makes the path writeable and removes it after a fixed delay
[ "RemoveMountPath", "makes", "the", "path", "writeable", "and", "removes", "it", "after", "a", "fixed", "delay" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L685-L721
22,216
libopenstorage/openstorage
pkg/mount/mount.go
New
func New( mounterType MountType, mountImpl MountImpl, identifiers []string, customMounter CustomMounter, allowedDirs []string, trashLocation string, ) (Manager, error) { if mountImpl == nil { mountImpl = &DefaultMounter{} } switch mounterType { case DeviceMount: return NewDeviceMounter(identifiers, moun...
go
func New( mounterType MountType, mountImpl MountImpl, identifiers []string, customMounter CustomMounter, allowedDirs []string, trashLocation string, ) (Manager, error) { if mountImpl == nil { mountImpl = &DefaultMounter{} } switch mounterType { case DeviceMount: return NewDeviceMounter(identifiers, moun...
[ "func", "New", "(", "mounterType", "MountType", ",", "mountImpl", "MountImpl", ",", "identifiers", "[", "]", "string", ",", "customMounter", "CustomMounter", ",", "allowedDirs", "[", "]", "string", ",", "trashLocation", "string", ",", ")", "(", "Manager", ",",...
// New returns a new Mount Manager
[ "New", "returns", "a", "new", "Mount", "Manager" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/pkg/mount/mount.go#L785-L809
22,217
libopenstorage/openstorage
graph/drivers/chainfs/unsupported.go
Init
func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) { return nil, errUnsupported }
go
func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) { return nil, errUnsupported }
[ "func", "Init", "(", "home", "string", ",", "options", "[", "]", "string", ",", "uidMaps", ",", "gidMaps", "[", "]", "idtools", ".", "IDMap", ")", "(", "graphdriver", ".", "Driver", ",", "error", ")", "{", "return", "nil", ",", "errUnsupported", "\n", ...
// Init initializes the graphdriver
[ "Init", "initializes", "the", "graphdriver" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/graph/drivers/chainfs/unsupported.go#L25-L27
22,218
libopenstorage/openstorage
api/status.go
StatusSimpleValueOf
func StatusSimpleValueOf(s string) (Status, error) { obj, err := simpleValueOf("status", Status_value, s) return Status(obj), err }
go
func StatusSimpleValueOf(s string) (Status, error) { obj, err := simpleValueOf("status", Status_value, s) return Status(obj), err }
[ "func", "StatusSimpleValueOf", "(", "s", "string", ")", "(", "Status", ",", "error", ")", "{", "obj", ",", "err", ":=", "simpleValueOf", "(", "\"", "\"", ",", "Status_value", ",", "s", ")", "\n", "return", "Status", "(", "obj", ")", ",", "err", "\n",...
// StatusSimpleValueOf returns the string format of Status
[ "StatusSimpleValueOf", "returns", "the", "string", "format", "of", "Status" ]
71b7f37f99c70e697aa31ca57fa8fb1404629329
https://github.com/libopenstorage/openstorage/blob/71b7f37f99c70e697aa31ca57fa8fb1404629329/api/status.go#L35-L38
22,219
gorilla/rpc
json/server.go
Method
func (c *CodecRequest) Method() (string, error) { if c.err == nil { return c.request.Method, nil } return "", c.err }
go
func (c *CodecRequest) Method() (string, error) { if c.err == nil { return c.request.Method, nil } return "", c.err }
[ "func", "(", "c", "*", "CodecRequest", ")", "Method", "(", ")", "(", "string", ",", "error", ")", "{", "if", "c", ".", "err", "==", "nil", "{", "return", "c", ".", "request", ".", "Method", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ","...
// Method returns the RPC method for the current request. // // The method uses a dotted notation as in "Service.Method".
[ "Method", "returns", "the", "RPC", "method", "for", "the", "current", "request", ".", "The", "method", "uses", "a", "dotted", "notation", "as", "in", "Service", ".", "Method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/json/server.go#L85-L90
22,220
gorilla/rpc
json/server.go
WriteResponse
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}, methodErr error) error { if c.err != nil { return c.err } res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } if methodErr != nil { // Propagate error message as string. res.Error = methodErr.Error(...
go
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}, methodErr error) error { if c.err != nil { return c.err } res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } if methodErr != nil { // Propagate error message as string. res.Error = methodErr.Error(...
[ "func", "(", "c", "*", "CodecRequest", ")", "WriteResponse", "(", "w", "http", ".", "ResponseWriter", ",", "reply", "interface", "{", "}", ",", "methodErr", "error", ")", "error", "{", "if", "c", ".", "err", "!=", "nil", "{", "return", "c", ".", "err...
// WriteResponse encodes the response and writes it to the ResponseWriter. // // The err parameter is the error resulted from calling the RPC method, // or nil if there was no error.
[ "WriteResponse", "encodes", "the", "response", "and", "writes", "it", "to", "the", "ResponseWriter", ".", "The", "err", "parameter", "is", "the", "error", "resulted", "from", "calling", "the", "RPC", "method", "or", "nil", "if", "there", "was", "no", "error"...
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/json/server.go#L111-L136
22,221
gorilla/rpc
v2/server.go
HasMethod
func (s *Server) HasMethod(method string) bool { if _, _, err := s.services.get(method); err == nil { return true } return false }
go
func (s *Server) HasMethod(method string) bool { if _, _, err := s.services.get(method); err == nil { return true } return false }
[ "func", "(", "s", "*", "Server", ")", "HasMethod", "(", "method", "string", ")", "bool", "{", "if", "_", ",", "_", ",", "err", ":=", "s", ".", "services", ".", "get", "(", "method", ")", ";", "err", "==", "nil", "{", "return", "true", "\n", "}"...
// HasMethod returns true if the given method is registered. // // The method uses a dotted notation as in "Service.Method".
[ "HasMethod", "returns", "true", "if", "the", "given", "method", "is", "registered", ".", "The", "method", "uses", "a", "dotted", "notation", "as", "in", "Service", ".", "Method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/server.go#L139-L144
22,222
gorilla/rpc
map.go
register
func (m *serviceMap) register(rcvr interface{}, name string, passReq bool) error { // Setup service. s := &service{ name: name, rcvr: reflect.ValueOf(rcvr), rcvrType: reflect.TypeOf(rcvr), methods: make(map[string]*serviceMethod), passReq: passReq, } if name == "" { s.name = reflect.Indirect(s...
go
func (m *serviceMap) register(rcvr interface{}, name string, passReq bool) error { // Setup service. s := &service{ name: name, rcvr: reflect.ValueOf(rcvr), rcvrType: reflect.TypeOf(rcvr), methods: make(map[string]*serviceMethod), passReq: passReq, } if name == "" { s.name = reflect.Indirect(s...
[ "func", "(", "m", "*", "serviceMap", ")", "register", "(", "rcvr", "interface", "{", "}", ",", "name", "string", ",", "passReq", "bool", ")", "error", "{", "// Setup service.", "s", ":=", "&", "service", "{", "name", ":", "name", ",", "rcvr", ":", "r...
// register adds a new service using reflection to extract its methods.
[ "register", "adds", "a", "new", "service", "using", "reflection", "to", "extract", "its", "methods", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/map.go#L53-L140
22,223
gorilla/rpc
map.go
get
func (m *serviceMap) get(method string) (*service, *serviceMethod, error) { parts := strings.Split(method, ".") if len(parts) != 2 { err := fmt.Errorf("rpc: service/method request ill-formed: %q", method) return nil, nil, err } m.mutex.Lock() service := m.services[parts[0]] m.mutex.Unlock() if service == nil...
go
func (m *serviceMap) get(method string) (*service, *serviceMethod, error) { parts := strings.Split(method, ".") if len(parts) != 2 { err := fmt.Errorf("rpc: service/method request ill-formed: %q", method) return nil, nil, err } m.mutex.Lock() service := m.services[parts[0]] m.mutex.Unlock() if service == nil...
[ "func", "(", "m", "*", "serviceMap", ")", "get", "(", "method", "string", ")", "(", "*", "service", ",", "*", "serviceMethod", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "method", ",", "\"", "\"", ")", "\n", "if", "len", ...
// get returns a registered service given a method name. // // The method name uses a dotted notation as in "Service.Method".
[ "get", "returns", "a", "registered", "service", "given", "a", "method", "name", ".", "The", "method", "name", "uses", "a", "dotted", "notation", "as", "in", "Service", ".", "Method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/map.go#L145-L164
22,224
gorilla/rpc
map.go
isExportedOrBuiltin
func isExportedOrBuiltin(t reflect.Type) bool { for t.Kind() == reflect.Ptr { t = t.Elem() } // PkgPath will be non-empty even for an exported type, // so we need to check the type name as well. return isExported(t.Name()) || t.PkgPath() == "" }
go
func isExportedOrBuiltin(t reflect.Type) bool { for t.Kind() == reflect.Ptr { t = t.Elem() } // PkgPath will be non-empty even for an exported type, // so we need to check the type name as well. return isExported(t.Name()) || t.PkgPath() == "" }
[ "func", "isExportedOrBuiltin", "(", "t", "reflect", ".", "Type", ")", "bool", "{", "for", "t", ".", "Kind", "(", ")", "==", "reflect", ".", "Ptr", "{", "t", "=", "t", ".", "Elem", "(", ")", "\n", "}", "\n", "// PkgPath will be non-empty even for an expor...
// isExportedOrBuiltin returns true if a type is exported or a builtin.
[ "isExportedOrBuiltin", "returns", "true", "if", "a", "type", "is", "exported", "or", "a", "builtin", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/map.go#L173-L180
22,225
gorilla/rpc
v2/compression_selector.go
Select
func (*CompressionSelector) Select(r *http.Request) Encoder { encHeader := r.Header.Get("Accept-Encoding") encTypes := strings.FieldsFunc(encHeader, func(r rune) bool { return unicode.IsSpace(r) || r == ',' }) for _, enc := range encTypes { switch enc { case "gzip": return &gzipEncoder{} case "deflate":...
go
func (*CompressionSelector) Select(r *http.Request) Encoder { encHeader := r.Header.Get("Accept-Encoding") encTypes := strings.FieldsFunc(encHeader, func(r rune) bool { return unicode.IsSpace(r) || r == ',' }) for _, enc := range encTypes { switch enc { case "gzip": return &gzipEncoder{} case "deflate":...
[ "func", "(", "*", "CompressionSelector", ")", "Select", "(", "r", "*", "http", ".", "Request", ")", "Encoder", "{", "encHeader", ":=", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "encTypes", ":=", "strings", ".", "FieldsFunc", "(", "e...
// Select method selects the correct compression encoder based on http HEADER.
[ "Select", "method", "selects", "the", "correct", "compression", "encoder", "based", "on", "http", "HEADER", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/compression_selector.go#L64-L80
22,226
gorilla/rpc
v2/json2/client.go
EncodeClientRequest
func EncodeClientRequest(method string, args interface{}) ([]byte, error) { c := &clientRequest{ Version: "2.0", Method: method, Params: args, Id: uint64(rand.Int63()), } return json.Marshal(c) }
go
func EncodeClientRequest(method string, args interface{}) ([]byte, error) { c := &clientRequest{ Version: "2.0", Method: method, Params: args, Id: uint64(rand.Int63()), } return json.Marshal(c) }
[ "func", "EncodeClientRequest", "(", "method", "string", ",", "args", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "c", ":=", "&", "clientRequest", "{", "Version", ":", "\"", "\"", ",", "Method", ":", "method", ",", "Para...
// EncodeClientRequest encodes parameters for a JSON-RPC client request.
[ "EncodeClientRequest", "encodes", "parameters", "for", "a", "JSON", "-", "RPC", "client", "request", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/json2/client.go#L42-L50
22,227
gorilla/rpc
v2/protorpc/server.go
ReadRequest
func (c *CodecRequest) ReadRequest(args interface{}) error { if c.err == nil { if c.request.Params != nil { c.err = json.Unmarshal(*c.request.Params, args) } else { c.err = errors.New("rpc: method request ill-formed: missing params field") } } return c.err }
go
func (c *CodecRequest) ReadRequest(args interface{}) error { if c.err == nil { if c.request.Params != nil { c.err = json.Unmarshal(*c.request.Params, args) } else { c.err = errors.New("rpc: method request ill-formed: missing params field") } } return c.err }
[ "func", "(", "c", "*", "CodecRequest", ")", "ReadRequest", "(", "args", "interface", "{", "}", ")", "error", "{", "if", "c", ".", "err", "==", "nil", "{", "if", "c", ".", "request", ".", "Params", "!=", "nil", "{", "c", ".", "err", "=", "json", ...
// ReadRequest fills the request object for the RPC method.
[ "ReadRequest", "fills", "the", "request", "object", "for", "the", "RPC", "method", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/protorpc/server.go#L106-L115
22,228
gorilla/rpc
v2/protorpc/server.go
WriteResponse
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}) { res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } c.writeServerResponse(w, 200, res) }
go
func (c *CodecRequest) WriteResponse(w http.ResponseWriter, reply interface{}) { res := &serverResponse{ Result: reply, Error: &null, Id: c.request.Id, } c.writeServerResponse(w, 200, res) }
[ "func", "(", "c", "*", "CodecRequest", ")", "WriteResponse", "(", "w", "http", ".", "ResponseWriter", ",", "reply", "interface", "{", "}", ")", "{", "res", ":=", "&", "serverResponse", "{", "Result", ":", "reply", ",", "Error", ":", "&", "null", ",", ...
// WriteResponse encodes the response and writes it to the ResponseWriter.
[ "WriteResponse", "encodes", "the", "response", "and", "writes", "it", "to", "the", "ResponseWriter", "." ]
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/protorpc/server.go#L118-L125
22,229
gorilla/rpc
v2/json2/server.go
NewCustomCodecWithErrorMapper
func NewCustomCodecWithErrorMapper(encSel rpc.EncoderSelector, errorMapper func(error) error) *Codec { return &Codec{ encSel: encSel, errorMapper: errorMapper, } }
go
func NewCustomCodecWithErrorMapper(encSel rpc.EncoderSelector, errorMapper func(error) error) *Codec { return &Codec{ encSel: encSel, errorMapper: errorMapper, } }
[ "func", "NewCustomCodecWithErrorMapper", "(", "encSel", "rpc", ".", "EncoderSelector", ",", "errorMapper", "func", "(", "error", ")", "error", ")", "*", "Codec", "{", "return", "&", "Codec", "{", "encSel", ":", "encSel", ",", "errorMapper", ":", "errorMapper",...
// NewCustomCodecWithErrorMapper returns a new JSON Codec based on the passed encoder selector // and also accepts an errorMapper function. // The errorMapper function will be called if the Service implementation returns an error, with that // error as a param, replacing it by the value returned by this function. This ...
[ "NewCustomCodecWithErrorMapper", "returns", "a", "new", "JSON", "Codec", "based", "on", "the", "passed", "encoder", "selector", "and", "also", "accepts", "an", "errorMapper", "function", ".", "The", "errorMapper", "function", "will", "be", "called", "if", "the", ...
bffcfa752ad4e523cc8f720afeb5b985ed41ae16
https://github.com/gorilla/rpc/blob/bffcfa752ad4e523cc8f720afeb5b985ed41ae16/v2/json2/server.go#L73-L78
22,230
brocaar/lorawan
phypayload.go
MarshalBinary
func (k AES128Key) MarshalBinary() ([]byte, error) { b := make([]byte, len(k)) for i, v := range k { // little endian b[len(k)-i-1] = v } return b, nil }
go
func (k AES128Key) MarshalBinary() ([]byte, error) { b := make([]byte, len(k)) for i, v := range k { // little endian b[len(k)-i-1] = v } return b, nil }
[ "func", "(", "k", "AES128Key", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "len", "(", "k", ")", ")", "\n", "for", "i", ",", "v", ":=", "range", "k", "{", "//...
// MarshalBinary encodes the key to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "key", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L107-L114
22,231
brocaar/lorawan
phypayload.go
UnmarshalBinary
func (k *AES128Key) UnmarshalBinary(data []byte) error { if len(data) != len(k) { return fmt.Errorf("lorawan: %d bytes of data are expected", len(k)) } for i, v := range data { // little endian k[len(k)-i-1] = v } return nil }
go
func (k *AES128Key) UnmarshalBinary(data []byte) error { if len(data) != len(k) { return fmt.Errorf("lorawan: %d bytes of data are expected", len(k)) } for i, v := range data { // little endian k[len(k)-i-1] = v } return nil }
[ "func", "(", "k", "*", "AES128Key", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "!=", "len", "(", "k", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "k",...
// UnmarshalBinary decodes the key from a slice of bytes.
[ "UnmarshalBinary", "decodes", "the", "key", "from", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L117-L128
22,232
brocaar/lorawan
phypayload.go
SetUplinkDataMIC
func (p *PHYPayload) SetUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, fNwkSIntKey, sNwkSIntKey AES128Key) error { mic, err := p.calculateUplinkDataMIC(macVersion, confFCnt, txDR, txCh, fNwkSIntKey, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetUplinkDataMIC(macVersion MACVersion, confFCnt uint32, txDR, txCh uint8, fNwkSIntKey, sNwkSIntKey AES128Key) error { mic, err := p.calculateUplinkDataMIC(macVersion, confFCnt, txDR, txCh, fNwkSIntKey, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetUplinkDataMIC", "(", "macVersion", "MACVersion", ",", "confFCnt", "uint32", ",", "txDR", ",", "txCh", "uint8", ",", "fNwkSIntKey", ",", "sNwkSIntKey", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p...
// SetUplinkDataMIC calculates and sets the MIC field for uplink data frames. // The confirmed frame-counter, TX data-rate TX channel index and SNwkSIntKey // are only required for LoRaWAN 1.1 and can be left blank otherwise.
[ "SetUplinkDataMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "uplink", "data", "frames", ".", "The", "confirmed", "frame", "-", "counter", "TX", "data", "-", "rate", "TX", "channel", "index", "and", "SNwkSIntKey", "are", "only", "required", ...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L174-L181
22,233
brocaar/lorawan
phypayload.go
SetDownlinkDataMIC
func (p *PHYPayload) SetDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) error { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) error { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetDownlinkDataMIC", "(", "macVersion", "MACVersion", ",", "confFCnt", "uint32", ",", "sNwkSIntKey", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p", ".", "calculateDownlinkDataMIC", "(", "macVersion", ",...
// SetDownlinkDataMIC calculates and sets the MIC field for downlink data frames. // The confirmed frame-counter and is only required for LoRaWAN 1.1 and can be // left blank otherwise.
[ "SetDownlinkDataMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "downlink", "data", "frames", ".", "The", "confirmed", "frame", "-", "counter", "and", "is", "only", "required", "for", "LoRaWAN", "1", ".", "1", "and", "can", "be", "left", "...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L200-L207
22,234
brocaar/lorawan
phypayload.go
ValidateDownlinkDataMIC
func (p PHYPayload) ValidateDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) (bool, error) { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return false, err } return p.MIC == mic, nil }
go
func (p PHYPayload) ValidateDownlinkDataMIC(macVersion MACVersion, confFCnt uint32, sNwkSIntKey AES128Key) (bool, error) { mic, err := p.calculateDownlinkDataMIC(macVersion, confFCnt, sNwkSIntKey) if err != nil { return false, err } return p.MIC == mic, nil }
[ "func", "(", "p", "PHYPayload", ")", "ValidateDownlinkDataMIC", "(", "macVersion", "MACVersion", ",", "confFCnt", "uint32", ",", "sNwkSIntKey", "AES128Key", ")", "(", "bool", ",", "error", ")", "{", "mic", ",", "err", ":=", "p", ".", "calculateDownlinkDataMIC"...
// ValidateDownlinkDataMIC validates the MIC of a downlink data frame. // In order to validate the MIC, the FCnt value must first be set to the // full 32 bit frame-counter value, as only the 16 least-significant bits // are transmitted. // The confirmed frame-counter and is only required for LoRaWAN 1.1 and can be // ...
[ "ValidateDownlinkDataMIC", "validates", "the", "MIC", "of", "a", "downlink", "data", "frame", ".", "In", "order", "to", "validate", "the", "MIC", "the", "FCnt", "value", "must", "first", "be", "set", "to", "the", "full", "32", "bit", "frame", "-", "counter...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L215-L221
22,235
brocaar/lorawan
phypayload.go
SetUplinkJoinMIC
func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetUplinkJoinMIC(key AES128Key) error { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetUplinkJoinMIC", "(", "key", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p", ".", "calculateUplinkJoinMIC", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// SetUplinkJoinMIC calculates and sets the MIC field for uplink join requests.
[ "SetUplinkJoinMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "uplink", "join", "requests", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L224-L231
22,236
brocaar/lorawan
phypayload.go
ValidateUplinkJoinMIC
func (p PHYPayload) ValidateUplinkJoinMIC(key AES128Key) (bool, error) { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return false, err } return p.MIC == mic, nil }
go
func (p PHYPayload) ValidateUplinkJoinMIC(key AES128Key) (bool, error) { mic, err := p.calculateUplinkJoinMIC(key) if err != nil { return false, err } return p.MIC == mic, nil }
[ "func", "(", "p", "PHYPayload", ")", "ValidateUplinkJoinMIC", "(", "key", "AES128Key", ")", "(", "bool", ",", "error", ")", "{", "mic", ",", "err", ":=", "p", ".", "calculateUplinkJoinMIC", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// ValidateUplinkJoinMIC validates the MIC of an uplink join request.
[ "ValidateUplinkJoinMIC", "validates", "the", "MIC", "of", "an", "uplink", "join", "request", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L234-L240
22,237
brocaar/lorawan
phypayload.go
SetDownlinkJoinMIC
func (p *PHYPayload) SetDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) error { mic, err := p.calculateDownlinkJoinMIC(joinReqType, joinEUI, devNonce, key) if err != nil { return err } p.MIC = mic return nil }
go
func (p *PHYPayload) SetDownlinkJoinMIC(joinReqType JoinType, joinEUI EUI64, devNonce DevNonce, key AES128Key) error { mic, err := p.calculateDownlinkJoinMIC(joinReqType, joinEUI, devNonce, key) if err != nil { return err } p.MIC = mic return nil }
[ "func", "(", "p", "*", "PHYPayload", ")", "SetDownlinkJoinMIC", "(", "joinReqType", "JoinType", ",", "joinEUI", "EUI64", ",", "devNonce", "DevNonce", ",", "key", "AES128Key", ")", "error", "{", "mic", ",", "err", ":=", "p", ".", "calculateDownlinkJoinMIC", "...
// SetDownlinkJoinMIC calculates and sets the MIC field for downlink join requests.
[ "SetDownlinkJoinMIC", "calculates", "and", "sets", "the", "MIC", "field", "for", "downlink", "join", "requests", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L243-L250
22,238
brocaar/lorawan
phypayload.go
EncryptFOpts
func (p *PHYPayload) EncryptFOpts(nwkSEncKey AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FHDR.FOpts) == 0 { return nil } var macB []byte for _, mac := range macPL.FHDR.FOpts { ...
go
func (p *PHYPayload) EncryptFOpts(nwkSEncKey AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FHDR.FOpts) == 0 { return nil } var macB []byte for _, mac := range macPL.FHDR.FOpts { ...
[ "func", "(", "p", "*", "PHYPayload", ")", "EncryptFOpts", "(", "nwkSEncKey", "AES128Key", ")", "error", "{", "macPL", ",", "ok", ":=", "p", ".", "MACPayload", ".", "(", "*", "MACPayload", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New...
// EncryptFOpts encrypts the FOpts with the given key.
[ "EncryptFOpts", "encrypts", "the", "FOpts", "with", "the", "given", "key", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L340-L376
22,239
brocaar/lorawan
phypayload.go
DecryptFOpts
func (p *PHYPayload) DecryptFOpts(nwkSEncKey AES128Key) error { if err := p.EncryptFOpts(nwkSEncKey); err != nil { return nil } return p.DecodeFOptsToMACCommands() }
go
func (p *PHYPayload) DecryptFOpts(nwkSEncKey AES128Key) error { if err := p.EncryptFOpts(nwkSEncKey); err != nil { return nil } return p.DecodeFOptsToMACCommands() }
[ "func", "(", "p", "*", "PHYPayload", ")", "DecryptFOpts", "(", "nwkSEncKey", "AES128Key", ")", "error", "{", "if", "err", ":=", "p", ".", "EncryptFOpts", "(", "nwkSEncKey", ")", ";", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n\n", "return"...
// DecryptFOpts decrypts the FOpts payload and decodes it into mac-command // structures.
[ "DecryptFOpts", "decrypts", "the", "FOpts", "payload", "and", "decodes", "it", "into", "mac", "-", "command", "structures", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L380-L386
22,240
brocaar/lorawan
phypayload.go
EncryptFRMPayload
func (p *PHYPayload) EncryptFRMPayload(key AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FRMPayload) == 0 { return nil } data, err := macPL.marshalPayload() if err != nil { ret...
go
func (p *PHYPayload) EncryptFRMPayload(key AES128Key) error { macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // nothing to encrypt if len(macPL.FRMPayload) == 0 { return nil } data, err := macPL.marshalPayload() if err != nil { ret...
[ "func", "(", "p", "*", "PHYPayload", ")", "EncryptFRMPayload", "(", "key", "AES128Key", ")", "error", "{", "macPL", ",", "ok", ":=", "p", ".", "MACPayload", ".", "(", "*", "MACPayload", ")", "\n", "if", "!", "ok", "{", "return", "errors", ".", "New",...
// EncryptFRMPayload encrypts the FRMPayload with the given key.
[ "EncryptFRMPayload", "encrypts", "the", "FRMPayload", "with", "the", "given", "key", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L389-L414
22,241
brocaar/lorawan
phypayload.go
DecryptFRMPayload
func (p *PHYPayload) DecryptFRMPayload(key AES128Key) error { if err := p.EncryptFRMPayload(key); err != nil { return err } macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // the FRMPayload contains MAC commands, which we need to unmars...
go
func (p *PHYPayload) DecryptFRMPayload(key AES128Key) error { if err := p.EncryptFRMPayload(key); err != nil { return err } macPL, ok := p.MACPayload.(*MACPayload) if !ok { return errors.New("lorawan: MACPayload must be of type *MACPayload") } // the FRMPayload contains MAC commands, which we need to unmars...
[ "func", "(", "p", "*", "PHYPayload", ")", "DecryptFRMPayload", "(", "key", "AES128Key", ")", "error", "{", "if", "err", ":=", "p", ".", "EncryptFRMPayload", "(", "key", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "macPL", "...
// DecryptFRMPayload decrypts the FRMPayload with the given key.
[ "DecryptFRMPayload", "decrypts", "the", "FRMPayload", "with", "the", "given", "key", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L417-L434
22,242
brocaar/lorawan
phypayload.go
MarshalText
func (p PHYPayload) MarshalText() ([]byte, error) { b, err := p.MarshalBinary() if err != nil { return nil, err } return []byte(base64.StdEncoding.EncodeToString(b)), nil }
go
func (p PHYPayload) MarshalText() ([]byte, error) { b, err := p.MarshalBinary() if err != nil { return nil, err } return []byte(base64.StdEncoding.EncodeToString(b)), nil }
[ "func", "(", "p", "PHYPayload", ")", "MarshalText", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ",", "err", ":=", "p", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}"...
// MarshalText encodes the PHYPayload into base64.
[ "MarshalText", "encodes", "the", "PHYPayload", "into", "base64", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L535-L541
22,243
brocaar/lorawan
phypayload.go
UnmarshalText
func (p *PHYPayload) UnmarshalText(text []byte) error { b, err := base64.StdEncoding.DecodeString(string(text)) if err != nil { return err } return p.UnmarshalBinary(b) }
go
func (p *PHYPayload) UnmarshalText(text []byte) error { b, err := base64.StdEncoding.DecodeString(string(text)) if err != nil { return err } return p.UnmarshalBinary(b) }
[ "func", "(", "p", "*", "PHYPayload", ")", "UnmarshalText", "(", "text", "[", "]", "byte", ")", "error", "{", "b", ",", "err", ":=", "base64", ".", "StdEncoding", ".", "DecodeString", "(", "string", "(", "text", ")", ")", "\n", "if", "err", "!=", "n...
// UnmarshalText decodes the PHYPayload from base64.
[ "UnmarshalText", "decodes", "the", "PHYPayload", "from", "base64", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L544-L550
22,244
brocaar/lorawan
phypayload.go
MarshalJSON
func (p PHYPayload) MarshalJSON() ([]byte, error) { type phyAlias PHYPayload return json.Marshal(phyAlias(p)) }
go
func (p PHYPayload) MarshalJSON() ([]byte, error) { type phyAlias PHYPayload return json.Marshal(phyAlias(p)) }
[ "func", "(", "p", "PHYPayload", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "type", "phyAlias", "PHYPayload", "\n", "return", "json", ".", "Marshal", "(", "phyAlias", "(", "p", ")", ")", "\n", "}" ]
// MarshalJSON encodes the PHYPayload into JSON.
[ "MarshalJSON", "encodes", "the", "PHYPayload", "into", "JSON", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/phypayload.go#L553-L556
22,245
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
GetCommandPayload
func GetCommandPayload(uplink bool, c CID) (CommandPayload, error) { v, ok := commandPayloadRegistry[uplink][c] if !ok { return nil, ErrNoPayloadForCID } return v(), nil }
go
func GetCommandPayload(uplink bool, c CID) (CommandPayload, error) { v, ok := commandPayloadRegistry[uplink][c] if !ok { return nil, ErrNoPayloadForCID } return v(), nil }
[ "func", "GetCommandPayload", "(", "uplink", "bool", ",", "c", "CID", ")", "(", "CommandPayload", ",", "error", ")", "{", "v", ",", "ok", ":=", "commandPayloadRegistry", "[", "uplink", "]", "[", "c", "]", "\n", "if", "!", "ok", "{", "return", "nil", "...
// GetCommandPayload returns a new CommandPayload for the given CID.
[ "GetCommandPayload", "returns", "a", "new", "CommandPayload", "for", "the", "given", "CID", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L61-L68
22,246
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
MarshalBinary
func (c Command) MarshalBinary() ([]byte, error) { b := []byte{byte(c.CID)} if c.Payload != nil { p, err := c.Payload.MarshalBinary() if err != nil { return nil, err } b = append(b, p...) } return b, nil }
go
func (c Command) MarshalBinary() ([]byte, error) { b := []byte{byte(c.CID)} if c.Payload != nil { p, err := c.Payload.MarshalBinary() if err != nil { return nil, err } b = append(b, p...) } return b, nil }
[ "func", "(", "c", "Command", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "[", "]", "byte", "{", "byte", "(", "c", ".", "CID", ")", "}", "\n\n", "if", "c", ".", "Payload", "!=", "nil", "{", "p", ...
// MarshalBinary encodes the command to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "command", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L84-L96
22,247
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
UnmarshalBinary
func (c *Command) UnmarshalBinary(uplink bool, data []byte) error { if len(data) == 0 { return errors.New("lorawan/applayer/multicastsetup: at least 1 byte is expected") } c.CID = CID(data[0]) p, err := GetCommandPayload(uplink, c.CID) if err != nil { if err == ErrNoPayloadForCID { return nil } return...
go
func (c *Command) UnmarshalBinary(uplink bool, data []byte) error { if len(data) == 0 { return errors.New("lorawan/applayer/multicastsetup: at least 1 byte is expected") } c.CID = CID(data[0]) p, err := GetCommandPayload(uplink, c.CID) if err != nil { if err == ErrNoPayloadForCID { return nil } return...
[ "func", "(", "c", "*", "Command", ")", "UnmarshalBinary", "(", "uplink", "bool", ",", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "...
// UnmarshalBinary decodes a slice of bytes into a command.
[ "UnmarshalBinary", "decodes", "a", "slice", "of", "bytes", "into", "a", "command", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L99-L120
22,248
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
Size
func (c Command) Size() int { if c.Payload != nil { return c.Payload.Size() + 1 } return 1 }
go
func (c Command) Size() int { if c.Payload != nil { return c.Payload.Size() + 1 } return 1 }
[ "func", "(", "c", "Command", ")", "Size", "(", ")", "int", "{", "if", "c", ".", "Payload", "!=", "nil", "{", "return", "c", ".", "Payload", ".", "Size", "(", ")", "+", "1", "\n", "}", "\n", "return", "1", "\n", "}" ]
// Size returns the size of the command in bytes.
[ "Size", "returns", "the", "size", "of", "the", "command", "in", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L123-L128
22,249
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
MarshalBinary
func (c Commands) MarshalBinary() ([]byte, error) { var out []byte for _, cmd := range c { b, err := cmd.MarshalBinary() if err != nil { return nil, err } out = append(out, b...) } return out, nil }
go
func (c Commands) MarshalBinary() ([]byte, error) { var out []byte for _, cmd := range c { b, err := cmd.MarshalBinary() if err != nil { return nil, err } out = append(out, b...) } return out, nil }
[ "func", "(", "c", "Commands", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "out", "[", "]", "byte", "\n\n", "for", "_", ",", "cmd", ":=", "range", "c", "{", "b", ",", "err", ":=", "cmd", ".", "MarshalBin...
// MarshalBinary encodes the commands to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "commands", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L134-L145
22,250
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
UnmarshalBinary
func (c *Commands) UnmarshalBinary(uplink bool, data []byte) error { var i int for i < len(data) { var cmd Command if err := cmd.UnmarshalBinary(uplink, data[i:]); err != nil { return err } i += cmd.Size() *c = append(*c, cmd) } return nil }
go
func (c *Commands) UnmarshalBinary(uplink bool, data []byte) error { var i int for i < len(data) { var cmd Command if err := cmd.UnmarshalBinary(uplink, data[i:]); err != nil { return err } i += cmd.Size() *c = append(*c, cmd) } return nil }
[ "func", "(", "c", "*", "Commands", ")", "UnmarshalBinary", "(", "uplink", "bool", ",", "data", "[", "]", "byte", ")", "error", "{", "var", "i", "int", "\n\n", "for", "i", "<", "len", "(", "data", ")", "{", "var", "cmd", "Command", "\n", "if", "er...
// UnmarshalBinary decodes a slice of bytes into a slice of commands.
[ "UnmarshalBinary", "decodes", "a", "slice", "of", "bytes", "into", "a", "slice", "of", "commands", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L148-L161
22,251
brocaar/lorawan
applayer/multicastsetup/multicastsetup.go
Size
func (p McGroupStatusAnsPayload) Size() int { var ansGroupMaskCount int for _, mask := range p.Status.AnsGroupMask { if mask { ansGroupMaskCount++ } } return 1 + (5 * ansGroupMaskCount) }
go
func (p McGroupStatusAnsPayload) Size() int { var ansGroupMaskCount int for _, mask := range p.Status.AnsGroupMask { if mask { ansGroupMaskCount++ } } return 1 + (5 * ansGroupMaskCount) }
[ "func", "(", "p", "McGroupStatusAnsPayload", ")", "Size", "(", ")", "int", "{", "var", "ansGroupMaskCount", "int", "\n", "for", "_", ",", "mask", ":=", "range", "p", ".", "Status", ".", "AnsGroupMask", "{", "if", "mask", "{", "ansGroupMaskCount", "++", "...
// Size returns the payload size in number of bytes.
[ "Size", "returns", "the", "payload", "size", "in", "number", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/multicastsetup.go#L251-L260
22,252
brocaar/lorawan
applayer/multicastsetup/keys.go
GetMcKEKey
func GetMcKEKey(mcRootKey lorawan.AES128Key) (lorawan.AES128Key, error) { return getKey(mcRootKey, [16]byte{}) }
go
func GetMcKEKey(mcRootKey lorawan.AES128Key) (lorawan.AES128Key, error) { return getKey(mcRootKey, [16]byte{}) }
[ "func", "GetMcKEKey", "(", "mcRootKey", "lorawan", ".", "AES128Key", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "return", "getKey", "(", "mcRootKey", ",", "[", "16", "]", "byte", "{", "}", ")", "\n", "}" ]
// GetMcKEKey returns the McKEKey given the McRootKey.
[ "GetMcKEKey", "returns", "the", "McKEKey", "given", "the", "McRootKey", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/keys.go#L23-L25
22,253
brocaar/lorawan
applayer/multicastsetup/keys.go
GetMcAppSKey
func GetMcAppSKey(mcKey lorawan.AES128Key, mcAddr lorawan.DevAddr) (lorawan.AES128Key, error) { b := [16]byte{0x01} mcAddrB, err := mcAddr.MarshalBinary() if err != nil { return lorawan.AES128Key{}, err } copy(b[1:5], mcAddrB) return getKey(mcKey, b) }
go
func GetMcAppSKey(mcKey lorawan.AES128Key, mcAddr lorawan.DevAddr) (lorawan.AES128Key, error) { b := [16]byte{0x01} mcAddrB, err := mcAddr.MarshalBinary() if err != nil { return lorawan.AES128Key{}, err } copy(b[1:5], mcAddrB) return getKey(mcKey, b) }
[ "func", "GetMcAppSKey", "(", "mcKey", "lorawan", ".", "AES128Key", ",", "mcAddr", "lorawan", ".", "DevAddr", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "b", ":=", "[", "16", "]", "byte", "{", "0x01", "}", "\n\n", "mcAddrB", ",", "...
// GetMcAppSKey returns the McAppSKey given the McKey and McAddr.
[ "GetMcAppSKey", "returns", "the", "McAppSKey", "given", "the", "McKey", "and", "McAddr", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/multicastsetup/keys.go#L28-L38
22,254
brocaar/lorawan
backend/joinserver/joinserver.go
NewHandler
func NewHandler(config HandlerConfig) (http.Handler, error) { if config.GetDeviceKeysByDevEUIFunc == nil { return nil, errors.New("backend/joinserver: GetDeviceKeysFunc must not be nil") } h := handler{ config: config, log: config.Logger, } if h.log == nil { h.log = &log.Logger{ Out: ioutil.Discard...
go
func NewHandler(config HandlerConfig) (http.Handler, error) { if config.GetDeviceKeysByDevEUIFunc == nil { return nil, errors.New("backend/joinserver: GetDeviceKeysFunc must not be nil") } h := handler{ config: config, log: config.Logger, } if h.log == nil { h.log = &log.Logger{ Out: ioutil.Discard...
[ "func", "NewHandler", "(", "config", "HandlerConfig", ")", "(", "http", ".", "Handler", ",", "error", ")", "{", "if", "config", ".", "GetDeviceKeysByDevEUIFunc", "==", "nil", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// NewHandler creates a new join-sever handler.
[ "NewHandler", "creates", "a", "new", "join", "-", "sever", "handler", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/backend/joinserver/joinserver.go#L42-L75
22,255
brocaar/lorawan
fhdr.go
NetIDType
func (a DevAddr) NetIDType() int { for i := 0; i < 8; i++ { if a[0]&(0xff<<(byte(7-i))) == 0xff&(0xff<<(byte(8-i))) { return i } } panic("NetIDType bug!") }
go
func (a DevAddr) NetIDType() int { for i := 0; i < 8; i++ { if a[0]&(0xff<<(byte(7-i))) == 0xff&(0xff<<(byte(8-i))) { return i } } panic("NetIDType bug!") }
[ "func", "(", "a", "DevAddr", ")", "NetIDType", "(", ")", "int", "{", "for", "i", ":=", "0", ";", "i", "<", "8", ";", "i", "++", "{", "if", "a", "[", "0", "]", "&", "(", "0xff", "<<", "(", "byte", "(", "7", "-", "i", ")", ")", ")", "==",...
// NetIDType returns the NetID type of the DevAddr.
[ "NetIDType", "returns", "the", "NetID", "type", "of", "the", "DevAddr", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L14-L21
22,256
brocaar/lorawan
fhdr.go
NwkID
func (a DevAddr) NwkID() []byte { switch a.NetIDType() { case 0: return a.getNwkID(1, 6) case 1: return a.getNwkID(2, 6) case 2: return a.getNwkID(3, 9) case 3: return a.getNwkID(4, 10) case 4: return a.getNwkID(5, 11) case 5: return a.getNwkID(6, 13) case 6: return a.getNwkID(7, 15) case 7: re...
go
func (a DevAddr) NwkID() []byte { switch a.NetIDType() { case 0: return a.getNwkID(1, 6) case 1: return a.getNwkID(2, 6) case 2: return a.getNwkID(3, 9) case 3: return a.getNwkID(4, 10) case 4: return a.getNwkID(5, 11) case 5: return a.getNwkID(6, 13) case 6: return a.getNwkID(7, 15) case 7: re...
[ "func", "(", "a", "DevAddr", ")", "NwkID", "(", ")", "[", "]", "byte", "{", "switch", "a", ".", "NetIDType", "(", ")", "{", "case", "0", ":", "return", "a", ".", "getNwkID", "(", "1", ",", "6", ")", "\n", "case", "1", ":", "return", "a", ".",...
// NwkID returns the NwkID bits of the DevAddr.
[ "NwkID", "returns", "the", "NwkID", "bits", "of", "the", "DevAddr", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L24-L45
22,257
brocaar/lorawan
fhdr.go
SetAddrPrefix
func (a *DevAddr) SetAddrPrefix(netID NetID) { switch netID.Type() { case 0: a.setAddrPrefix(1, 6, netID) case 1: a.setAddrPrefix(2, 6, netID) case 2: a.setAddrPrefix(3, 9, netID) case 3: a.setAddrPrefix(4, 10, netID) case 4: a.setAddrPrefix(5, 11, netID) case 5: a.setAddrPrefix(6, 13, netID) case 6...
go
func (a *DevAddr) SetAddrPrefix(netID NetID) { switch netID.Type() { case 0: a.setAddrPrefix(1, 6, netID) case 1: a.setAddrPrefix(2, 6, netID) case 2: a.setAddrPrefix(3, 9, netID) case 3: a.setAddrPrefix(4, 10, netID) case 4: a.setAddrPrefix(5, 11, netID) case 5: a.setAddrPrefix(6, 13, netID) case 6...
[ "func", "(", "a", "*", "DevAddr", ")", "SetAddrPrefix", "(", "netID", "NetID", ")", "{", "switch", "netID", ".", "Type", "(", ")", "{", "case", "0", ":", "a", ".", "setAddrPrefix", "(", "1", ",", "6", ",", "netID", ")", "\n", "case", "1", ":", ...
// SetAddrPrefix sets the NetID based AddrPrefix.
[ "SetAddrPrefix", "sets", "the", "NetID", "based", "AddrPrefix", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L48-L67
22,258
brocaar/lorawan
fhdr.go
IsNetID
func (a DevAddr) IsNetID(netID NetID) bool { tempDevAddr := a tempDevAddr.SetAddrPrefix(netID) if a == tempDevAddr { return true } return false }
go
func (a DevAddr) IsNetID(netID NetID) bool { tempDevAddr := a tempDevAddr.SetAddrPrefix(netID) if a == tempDevAddr { return true } return false }
[ "func", "(", "a", "DevAddr", ")", "IsNetID", "(", "netID", "NetID", ")", "bool", "{", "tempDevAddr", ":=", "a", "\n", "tempDevAddr", ".", "SetAddrPrefix", "(", "netID", ")", "\n\n", "if", "a", "==", "tempDevAddr", "{", "return", "true", "\n", "}", "\n\...
// IsNetID returns a bool indicating if the NwkID matches the given NetID.
[ "IsNetID", "returns", "a", "bool", "indicating", "if", "the", "NwkID", "matches", "the", "given", "NetID", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/fhdr.go#L70-L79
22,259
brocaar/lorawan
netid.go
ID
func (n NetID) ID() []byte { switch n.Type() { case 0, 1: return n.getID(6) case 2: return n.getID(9) case 3, 4, 5, 6, 7: return n.getID(21) default: return nil } }
go
func (n NetID) ID() []byte { switch n.Type() { case 0, 1: return n.getID(6) case 2: return n.getID(9) case 3, 4, 5, 6, 7: return n.getID(21) default: return nil } }
[ "func", "(", "n", "NetID", ")", "ID", "(", ")", "[", "]", "byte", "{", "switch", "n", ".", "Type", "(", ")", "{", "case", "0", ",", "1", ":", "return", "n", ".", "getID", "(", "6", ")", "\n", "case", "2", ":", "return", "n", ".", "getID", ...
// ID returns the NetID ID part.
[ "ID", "returns", "the", "NetID", "ID", "part", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/netid.go#L20-L31
22,260
brocaar/lorawan
airtime/airtime.go
CalculateLoRaAirtime
func CalculateLoRaAirtime(payloadSize, sf, bandwidth, preambleNumber int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (time.Duration, error) { symbolDuration := CalculateLoRaSymbolDuration(sf, bandwidth) preambleDuration := CalculateLoRaPreambleDuration(symbolDuration, preambleNumber) payloa...
go
func CalculateLoRaAirtime(payloadSize, sf, bandwidth, preambleNumber int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (time.Duration, error) { symbolDuration := CalculateLoRaSymbolDuration(sf, bandwidth) preambleDuration := CalculateLoRaPreambleDuration(symbolDuration, preambleNumber) payloa...
[ "func", "CalculateLoRaAirtime", "(", "payloadSize", ",", "sf", ",", "bandwidth", ",", "preambleNumber", "int", ",", "codingRate", "CodingRate", ",", "headerEnabled", ",", "lowDataRateOptimization", "bool", ")", "(", "time", ".", "Duration", ",", "error", ")", "{...
// CalculateLoRaAirtime calculates the airtime for a LoRa modulated frame.
[ "CalculateLoRaAirtime", "calculates", "the", "airtime", "for", "a", "LoRa", "modulated", "frame", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L24-L34
22,261
brocaar/lorawan
airtime/airtime.go
CalculateLoRaSymbolDuration
func CalculateLoRaSymbolDuration(sf int, bandwidth int) time.Duration { return time.Duration((1 << uint(sf)) * 1000000 / bandwidth) }
go
func CalculateLoRaSymbolDuration(sf int, bandwidth int) time.Duration { return time.Duration((1 << uint(sf)) * 1000000 / bandwidth) }
[ "func", "CalculateLoRaSymbolDuration", "(", "sf", "int", ",", "bandwidth", "int", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "(", "1", "<<", "uint", "(", "sf", ")", ")", "*", "1000000", "/", "bandwidth", ")", "\n", "}" ]
// CalculateLoRaSymbolDuration calculates the LoRa symbol duration.
[ "CalculateLoRaSymbolDuration", "calculates", "the", "LoRa", "symbol", "duration", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L37-L39
22,262
brocaar/lorawan
airtime/airtime.go
CalculateLoRaPreambleDuration
func CalculateLoRaPreambleDuration(symbolDuration time.Duration, preambleNumber int) time.Duration { return time.Duration((100*preambleNumber)+425) * symbolDuration / 100 }
go
func CalculateLoRaPreambleDuration(symbolDuration time.Duration, preambleNumber int) time.Duration { return time.Duration((100*preambleNumber)+425) * symbolDuration / 100 }
[ "func", "CalculateLoRaPreambleDuration", "(", "symbolDuration", "time", ".", "Duration", ",", "preambleNumber", "int", ")", "time", ".", "Duration", "{", "return", "time", ".", "Duration", "(", "(", "100", "*", "preambleNumber", ")", "+", "425", ")", "*", "s...
// CalculateLoRaPreambleDuration calculates the LoRa preamble duration.
[ "CalculateLoRaPreambleDuration", "calculates", "the", "LoRa", "preamble", "duration", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L42-L44
22,263
brocaar/lorawan
airtime/airtime.go
CalculateLoRaPayloadSymbolNumber
func CalculateLoRaPayloadSymbolNumber(payloadSize, sf int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (int, error) { var pl, spreadingFactor, h, de, cr float64 if codingRate < 1 || codingRate > 4 { return 0, errors.New("codingRate must be between 1 - 4") } if lowDataRateOptimization { ...
go
func CalculateLoRaPayloadSymbolNumber(payloadSize, sf int, codingRate CodingRate, headerEnabled, lowDataRateOptimization bool) (int, error) { var pl, spreadingFactor, h, de, cr float64 if codingRate < 1 || codingRate > 4 { return 0, errors.New("codingRate must be between 1 - 4") } if lowDataRateOptimization { ...
[ "func", "CalculateLoRaPayloadSymbolNumber", "(", "payloadSize", ",", "sf", "int", ",", "codingRate", "CodingRate", ",", "headerEnabled", ",", "lowDataRateOptimization", "bool", ")", "(", "int", ",", "error", ")", "{", "var", "pl", ",", "spreadingFactor", ",", "h...
// CalculateLoRaPayloadSymbolNumber returns the number of symbols that make // up the packet payload and header.
[ "CalculateLoRaPayloadSymbolNumber", "returns", "the", "number", "of", "symbols", "that", "make", "up", "the", "packet", "payload", "and", "header", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/airtime/airtime.go#L48-L72
22,264
brocaar/lorawan
applayer/fragmentation/encode.go
Encode
func Encode(data []byte, fragmentSize, redundancy int) ([][]byte, error) { if len(data)%fragmentSize != 0 { return nil, errors.New("length of data must be a multiple of the given fragment-size") } // fragment the data into rows var dataRows [][]byte for i := 0; i < len(data)/fragmentSize; i++ { offset := i * ...
go
func Encode(data []byte, fragmentSize, redundancy int) ([][]byte, error) { if len(data)%fragmentSize != 0 { return nil, errors.New("length of data must be a multiple of the given fragment-size") } // fragment the data into rows var dataRows [][]byte for i := 0; i < len(data)/fragmentSize; i++ { offset := i * ...
[ "func", "Encode", "(", "data", "[", "]", "byte", ",", "fragmentSize", ",", "redundancy", "int", ")", "(", "[", "]", "[", "]", "byte", ",", "error", ")", "{", "if", "len", "(", "data", ")", "%", "fragmentSize", "!=", "0", "{", "return", "nil", ","...
// Encode encodes the given slice of bytes to fragments including forward error correction. // This is based on the proposed FEC code from the Fragmented Data Block Transport over // LoRaWAN recommendation.
[ "Encode", "encodes", "the", "given", "slice", "of", "bytes", "to", "fragments", "including", "forward", "error", "correction", ".", "This", "is", "based", "on", "the", "proposed", "FEC", "code", "from", "the", "Fragmented", "Data", "Block", "Transport", "over"...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/fragmentation/encode.go#L10-L39
22,265
brocaar/lorawan
backend/joinserver/session_keys.go
getJSIntKey
func getJSIntKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x06, devEUI, nwkKey) }
go
func getJSIntKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x06, devEUI, nwkKey) }
[ "func", "getJSIntKey", "(", "nwkKey", "lorawan", ".", "AES128Key", ",", "devEUI", "lorawan", ".", "EUI64", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "return", "getJSKey", "(", "0x06", ",", "devEUI", ",", "nwkKey", ")", "\n", "}" ]
// getJSIntKey returns the JSIntKey.
[ "getJSIntKey", "returns", "the", "JSIntKey", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/backend/joinserver/session_keys.go#L34-L36
22,266
brocaar/lorawan
backend/joinserver/session_keys.go
getJSEncKey
func getJSEncKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x05, devEUI, nwkKey) }
go
func getJSEncKey(nwkKey lorawan.AES128Key, devEUI lorawan.EUI64) (lorawan.AES128Key, error) { return getJSKey(0x05, devEUI, nwkKey) }
[ "func", "getJSEncKey", "(", "nwkKey", "lorawan", ".", "AES128Key", ",", "devEUI", "lorawan", ".", "EUI64", ")", "(", "lorawan", ".", "AES128Key", ",", "error", ")", "{", "return", "getJSKey", "(", "0x05", ",", "devEUI", ",", "nwkKey", ")", "\n", "}" ]
// getJSEncKey returns the JSEncKey.
[ "getJSEncKey", "returns", "the", "JSEncKey", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/backend/joinserver/session_keys.go#L39-L41
22,267
brocaar/lorawan
band/band.go
intSliceDiff
func intSliceDiff(x, y []int) []int { var out []int for _, cX := range x { found := false for _, cY := range y { if cX == cY { found = true break } } if !found { out = append(out, cX) } } for _, cY := range y { found := false for _, cX := range x { if cY == cX { found = true ...
go
func intSliceDiff(x, y []int) []int { var out []int for _, cX := range x { found := false for _, cY := range y { if cX == cY { found = true break } } if !found { out = append(out, cX) } } for _, cY := range y { found := false for _, cX := range x { if cY == cX { found = true ...
[ "func", "intSliceDiff", "(", "x", ",", "y", "[", "]", "int", ")", "[", "]", "int", "{", "var", "out", "[", "]", "int", "\n\n", "for", "_", ",", "cX", ":=", "range", "x", "{", "found", ":=", "false", "\n", "for", "_", ",", "cY", ":=", "range",...
// y that are not in x.
[ "y", "that", "are", "not", "in", "x", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/band/band.go#L558-L588
22,268
brocaar/lorawan
band/band.go
GetConfig
func GetConfig(name Name, repeaterCompatible bool, dt lorawan.DwellTime) (Band, error) { switch name { case AS_923, AS923: return newAS923Band(repeaterCompatible, dt) case AU_915_928, AU915: return newAU915Band(repeaterCompatible, dt) case CN_470_510, CN470: return newCN470Band(repeaterCompatible) case CN_77...
go
func GetConfig(name Name, repeaterCompatible bool, dt lorawan.DwellTime) (Band, error) { switch name { case AS_923, AS923: return newAS923Band(repeaterCompatible, dt) case AU_915_928, AU915: return newAU915Band(repeaterCompatible, dt) case CN_470_510, CN470: return newCN470Band(repeaterCompatible) case CN_77...
[ "func", "GetConfig", "(", "name", "Name", ",", "repeaterCompatible", "bool", ",", "dt", "lorawan", ".", "DwellTime", ")", "(", "Band", ",", "error", ")", "{", "switch", "name", "{", "case", "AS_923", ",", "AS923", ":", "return", "newAS923Band", "(", "rep...
// GetConfig returns the band configuration for the given band. // Please refer to the LoRaWAN specification for more details about the effect // of the repeater and dwell time arguments.
[ "GetConfig", "returns", "the", "band", "configuration", "for", "the", "given", "band", ".", "Please", "refer", "to", "the", "LoRaWAN", "specification", "for", "more", "details", "about", "the", "effect", "of", "the", "repeater", "and", "dwell", "time", "argume...
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/band/band.go#L602-L627
22,269
brocaar/lorawan
mac_commands.go
GetMACPayloadAndSize
func GetMACPayloadAndSize(uplink bool, c CID) (MACCommandPayload, int, error) { macPayloadMutex.RLock() defer macPayloadMutex.RUnlock() v, ok := macPayloadRegistry[uplink][c] if !ok { return nil, 0, fmt.Errorf("lorawan: payload unknown for uplink=%v and CID=%v", uplink, c) } return v.payload(), v.size, nil }
go
func GetMACPayloadAndSize(uplink bool, c CID) (MACCommandPayload, int, error) { macPayloadMutex.RLock() defer macPayloadMutex.RUnlock() v, ok := macPayloadRegistry[uplink][c] if !ok { return nil, 0, fmt.Errorf("lorawan: payload unknown for uplink=%v and CID=%v", uplink, c) } return v.payload(), v.size, nil }
[ "func", "GetMACPayloadAndSize", "(", "uplink", "bool", ",", "c", "CID", ")", "(", "MACCommandPayload", ",", "int", ",", "error", ")", "{", "macPayloadMutex", ".", "RLock", "(", ")", "\n", "defer", "macPayloadMutex", ".", "RUnlock", "(", ")", "\n\n", "v", ...
// GetMACPayloadAndSize returns a new MACCommandPayload instance and it's size.
[ "GetMACPayloadAndSize", "returns", "a", "new", "MACCommandPayload", "instance", "and", "it", "s", "size", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L134-L144
22,270
brocaar/lorawan
mac_commands.go
RegisterProprietaryMACCommand
func RegisterProprietaryMACCommand(uplink bool, cid CID, payloadSize int) error { if !(cid >= 128 && cid <= 255) { return fmt.Errorf("lorawan: invalid CID %x", byte(cid)) } if payloadSize == 0 { // no need to register the payload size return nil } macPayloadMutex.Lock() defer macPayloadMutex.Unlock() ma...
go
func RegisterProprietaryMACCommand(uplink bool, cid CID, payloadSize int) error { if !(cid >= 128 && cid <= 255) { return fmt.Errorf("lorawan: invalid CID %x", byte(cid)) } if payloadSize == 0 { // no need to register the payload size return nil } macPayloadMutex.Lock() defer macPayloadMutex.Unlock() ma...
[ "func", "RegisterProprietaryMACCommand", "(", "uplink", "bool", ",", "cid", "CID", ",", "payloadSize", "int", ")", "error", "{", "if", "!", "(", "cid", ">=", "128", "&&", "cid", "<=", "255", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// RegisterProprietaryMACCommand registers a proprietary MAC command. Note // that there is no need to call this when the size of the payload is > 0 bytes.
[ "RegisterProprietaryMACCommand", "registers", "a", "proprietary", "MAC", "command", ".", "Note", "that", "there", "is", "no", "need", "to", "call", "this", "when", "the", "size", "of", "the", "payload", "is", ">", "0", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L148-L167
22,271
brocaar/lorawan
mac_commands.go
UnmarshalBinary
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error { p.Bytes = data return nil }
go
func (p *ProprietaryMACCommandPayload) UnmarshalBinary(data []byte) error { p.Bytes = data return nil }
[ "func", "(", "p", "*", "ProprietaryMACCommandPayload", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "p", ".", "Bytes", "=", "data", "\n", "return", "nil", "\n", "}" ]
// UnmarshalBinary decodes the object from a slice of bytes.
[ "UnmarshalBinary", "decodes", "the", "object", "from", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L228-L231
22,272
brocaar/lorawan
mac_commands.go
MarshalBinary
func (p TXParamSetupReqPayload) MarshalBinary() ([]byte, error) { var b uint8 for i, v := range []uint8{8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36} { if v == p.MaxEIRP { b = uint8(i) } } if b == 0 { return nil, errors.New("lorawan: invalid MaxEIRP value") } if p.UplinkDwellTime == Dwe...
go
func (p TXParamSetupReqPayload) MarshalBinary() ([]byte, error) { var b uint8 for i, v := range []uint8{8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36} { if v == p.MaxEIRP { b = uint8(i) } } if b == 0 { return nil, errors.New("lorawan: invalid MaxEIRP value") } if p.UplinkDwellTime == Dwe...
[ "func", "(", "p", "TXParamSetupReqPayload", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "b", "uint8", "\n", "for", "i", ",", "v", ":=", "range", "[", "]", "uint8", "{", "8", ",", "10", ",", "12", ",", "...
// MarshalBinary encodes the object into a bytes.
[ "MarshalBinary", "encodes", "the", "object", "into", "a", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L706-L725
22,273
brocaar/lorawan
mac_commands.go
decodeDataPayloadToMACCommands
func decodeDataPayloadToMACCommands(uplink bool, payloads []Payload) ([]Payload, error) { if len(payloads) != 1 { return nil, errors.New("lorawan: exactly one Payload expected") } dataPL, ok := payloads[0].(*DataPayload) if !ok { return nil, fmt.Errorf("lorawan: expected *DataPayload, got %T", payloads[0]) } ...
go
func decodeDataPayloadToMACCommands(uplink bool, payloads []Payload) ([]Payload, error) { if len(payloads) != 1 { return nil, errors.New("lorawan: exactly one Payload expected") } dataPL, ok := payloads[0].(*DataPayload) if !ok { return nil, fmt.Errorf("lorawan: expected *DataPayload, got %T", payloads[0]) } ...
[ "func", "decodeDataPayloadToMACCommands", "(", "uplink", "bool", ",", "payloads", "[", "]", "Payload", ")", "(", "[", "]", "Payload", ",", "error", ")", "{", "if", "len", "(", "payloads", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "New",...
// decodeDataPayloadToMACCommands decodes a DataPayload into a slice of // MACCommands.
[ "decodeDataPayloadToMACCommands", "decodes", "a", "DataPayload", "into", "a", "slice", "of", "MACCommands", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/mac_commands.go#L1278-L1312
22,274
brocaar/lorawan
applayer/clocksync/clocksync.go
UnmarshalBinary
func (p *AppTimeAnsPayload) UnmarshalBinary(data []byte) error { if len(data) < p.Size() { return fmt.Errorf("lorawan/applayer/clocksync: %d bytes are expected", p.Size()) } p.TimeCorrection = int32(binary.LittleEndian.Uint32(data[0:4])) p.Param.TokenAns = uint8(data[4] & 0x0f) return nil }
go
func (p *AppTimeAnsPayload) UnmarshalBinary(data []byte) error { if len(data) < p.Size() { return fmt.Errorf("lorawan/applayer/clocksync: %d bytes are expected", p.Size()) } p.TimeCorrection = int32(binary.LittleEndian.Uint32(data[0:4])) p.Param.TokenAns = uint8(data[4] & 0x0f) return nil }
[ "func", "(", "p", "*", "AppTimeAnsPayload", ")", "UnmarshalBinary", "(", "data", "[", "]", "byte", ")", "error", "{", "if", "len", "(", "data", ")", "<", "p", ".", "Size", "(", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "p", ...
// UnmarshalBinary decoces the payload from a slice of bytes.
[ "UnmarshalBinary", "decoces", "the", "payload", "from", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/clocksync/clocksync.go#L253-L262
22,275
brocaar/lorawan
applayer/fragmentation/fragmentation.go
MarshalBinary
func (p DataFragmentPayload) MarshalBinary() ([]byte, error) { b := make([]byte, p.Size()) binary.LittleEndian.PutUint16(b[0:2], p.IndexAndN.N&0x3fff) b[1] |= (p.IndexAndN.FragIndex & 0x03) << 6 copy(b[2:], p.Payload) return b, nil }
go
func (p DataFragmentPayload) MarshalBinary() ([]byte, error) { b := make([]byte, p.Size()) binary.LittleEndian.PutUint16(b[0:2], p.IndexAndN.N&0x3fff) b[1] |= (p.IndexAndN.FragIndex & 0x03) << 6 copy(b[2:], p.Payload) return b, nil }
[ "func", "(", "p", "DataFragmentPayload", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "p", ".", "Size", "(", ")", ")", "\n\n", "binary", ".", "LittleEndian", ".", "P...
// MarshalBinary encodes the given payload to a slice of bytes.
[ "MarshalBinary", "encodes", "the", "given", "payload", "to", "a", "slice", "of", "bytes", "." ]
5bca41b178e93c384fb6442f55a2d692da890830
https://github.com/brocaar/lorawan/blob/5bca41b178e93c384fb6442f55a2d692da890830/applayer/fragmentation/fragmentation.go#L419-L427
22,276
Netflix/rend
server/listen.go
TCPListener
func TCPListener(port int) ListenConst { return func() (Listener, error) { listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { return nil, fmt.Errorf("Error binding to port %d: %v", port, err.Error()) } return &tcpListener{listener: listener}, nil } }
go
func TCPListener(port int) ListenConst { return func() (Listener, error) { listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) if err != nil { return nil, fmt.Errorf("Error binding to port %d: %v", port, err.Error()) } return &tcpListener{listener: listener}, nil } }
[ "func", "TCPListener", "(", "port", "int", ")", "ListenConst", "{", "return", "func", "(", ")", "(", "Listener", ",", "error", ")", "{", "listener", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"...
// TCPListener is a ListenConst that returns a tcp listener for the given port
[ "TCPListener", "is", "a", "ListenConst", "that", "returns", "a", "tcp", "listener", "for", "the", "given", "port" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/server/listen.go#L55-L63
22,277
Netflix/rend
server/listen.go
UnixListener
func UnixListener(path string) ListenConst { return func() (Listener, error) { err := os.Remove(path) if err != nil && !os.IsNotExist(err) { return nil, fmt.Errorf("Error removing previous unix socket file at %s", path) } listener, err := net.Listen("unix", path) if err != nil { return nil, fmt.Errorf...
go
func UnixListener(path string) ListenConst { return func() (Listener, error) { err := os.Remove(path) if err != nil && !os.IsNotExist(err) { return nil, fmt.Errorf("Error removing previous unix socket file at %s", path) } listener, err := net.Listen("unix", path) if err != nil { return nil, fmt.Errorf...
[ "func", "UnixListener", "(", "path", "string", ")", "ListenConst", "{", "return", "func", "(", ")", "(", "Listener", ",", "error", ")", "{", "err", ":=", "os", ".", "Remove", "(", "path", ")", "\n", "if", "err", "!=", "nil", "&&", "!", "os", ".", ...
// UnixListener is a ListenConst that returns a unix domain socket listener for the given path
[ "UnixListener", "is", "a", "ListenConst", "that", "returns", "a", "unix", "domain", "socket", "listener", "for", "the", "given", "path" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/server/listen.go#L78-L92
22,278
Netflix/rend
metrics/bulkcallback.go
RegisterBulkCallback
func RegisterBulkCallback(bcb BulkCallback) { id := atomic.AddUint32(curBulkCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } bulkCBs[id] = bcb }
go
func RegisterBulkCallback(bcb BulkCallback) { id := atomic.AddUint32(curBulkCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } bulkCBs[id] = bcb }
[ "func", "RegisterBulkCallback", "(", "bcb", "BulkCallback", ")", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curBulkCbID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumCallbacks", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n...
// RegisterBulkCallback registers a bulk callback which will be called every time // metrics are requested. // There is a maximum of 1024 bulk callbacks, after which adding a new one will panic.
[ "RegisterBulkCallback", "registers", "a", "bulk", "callback", "which", "will", "be", "called", "every", "time", "metrics", "are", "requested", ".", "There", "is", "a", "maximum", "of", "1024", "bulk", "callbacks", "after", "which", "adding", "a", "new", "one",...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/bulkcallback.go#L38-L46
22,279
Netflix/rend
metrics/gauges.go
AddIntGauge
func AddIntGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curIntGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many int gauges") } intgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeUint64 intgtags[id] = tgs return id }
go
func AddIntGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curIntGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many int gauges") } intgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeUint64 intgtags[id] = tgs return id }
[ "func", "AddIntGauge", "(", "name", "string", ",", "tgs", "Tags", ")", "uint32", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curIntGaugeID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumGauges", "{", "panic", "(", "\"", "\"", ")",...
// AddIntGauge registers an integer-based gauge and returns an ID that can be // used to update it. // There is a maximum of 1024 gauges, after which adding a new one will panic
[ "AddIntGauge", "registers", "an", "integer", "-", "based", "gauge", "and", "returns", "an", "ID", "that", "can", "be", "used", "to", "update", "it", ".", "There", "is", "a", "maximum", "of", "1024", "gauges", "after", "which", "adding", "a", "new", "one"...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L39-L54
22,280
Netflix/rend
metrics/gauges.go
AddFloatGauge
func AddFloatGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curFloatGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many float gauges") } floatgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeFloat64 floatgtags[id] = tgs return id }
go
func AddFloatGauge(name string, tgs Tags) uint32 { id := atomic.AddUint32(curFloatGaugeID, 1) - 1 if id >= maxNumGauges { panic("Too many float gauges") } floatgnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge tgs[TagDataType] = DataTypeFloat64 floatgtags[id] = tgs return id }
[ "func", "AddFloatGauge", "(", "name", "string", ",", "tgs", "Tags", ")", "uint32", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curFloatGaugeID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumGauges", "{", "panic", "(", "\"", "\"", ...
// AddFloatGauge registers a float-based gauge and returns an ID that can be // used to access it. // There is a maximum of 1024 gauges, after which adding a new one will panic
[ "AddFloatGauge", "registers", "a", "float", "-", "based", "gauge", "and", "returns", "an", "ID", "that", "can", "be", "used", "to", "access", "it", ".", "There", "is", "a", "maximum", "of", "1024", "gauges", "after", "which", "adding", "a", "new", "one",...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L59-L74
22,281
Netflix/rend
metrics/gauges.go
SetIntGauge
func SetIntGauge(id uint32, value uint64) { atomic.StoreUint64(&intgauges[id], value) }
go
func SetIntGauge(id uint32, value uint64) { atomic.StoreUint64(&intgauges[id], value) }
[ "func", "SetIntGauge", "(", "id", "uint32", ",", "value", "uint64", ")", "{", "atomic", ".", "StoreUint64", "(", "&", "intgauges", "[", "id", "]", ",", "value", ")", "\n", "}" ]
// SetIntGauge sets a gauge by the ID returned from AddIntGauge to the value given.
[ "SetIntGauge", "sets", "a", "gauge", "by", "the", "ID", "returned", "from", "AddIntGauge", "to", "the", "value", "given", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L77-L79
22,282
Netflix/rend
metrics/gauges.go
SetFloatGauge
func SetFloatGauge(id uint32, value float64) { // The float64 value needs to be converted into an int64 here because // there is no atomic store for float values. This is a literal // reinterpretation of the same exact bits. v2 := math.Float64bits(value) atomic.StoreUint64(&floatgauges[id], v2) }
go
func SetFloatGauge(id uint32, value float64) { // The float64 value needs to be converted into an int64 here because // there is no atomic store for float values. This is a literal // reinterpretation of the same exact bits. v2 := math.Float64bits(value) atomic.StoreUint64(&floatgauges[id], v2) }
[ "func", "SetFloatGauge", "(", "id", "uint32", ",", "value", "float64", ")", "{", "// The float64 value needs to be converted into an int64 here because", "// there is no atomic store for float values. This is a literal", "// reinterpretation of the same exact bits.", "v2", ":=", "math"...
// SetFloatGauge sets a gauge by the ID returned from AddFloatGauge to the value given.
[ "SetFloatGauge", "sets", "a", "gauge", "by", "the", "ID", "returned", "from", "AddFloatGauge", "to", "the", "value", "given", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/gauges.go#L82-L88
22,283
Netflix/rend
client/cmd/setget/main.go
fillKeys
func fillKeys(chans []chan []byte) { totalCap := 0 for _, c := range chans { totalCap += cap(c) } if totalCap < f.NumOps { panic("Channels cannot hold all the ops. Deadlock guaranteed.") } ci := 0 key := bytes.Repeat([]byte{byte('A')}, f.KeyLength) for i := 0; i < f.NumOps; i++ { key = nextKey(key) cha...
go
func fillKeys(chans []chan []byte) { totalCap := 0 for _, c := range chans { totalCap += cap(c) } if totalCap < f.NumOps { panic("Channels cannot hold all the ops. Deadlock guaranteed.") } ci := 0 key := bytes.Repeat([]byte{byte('A')}, f.KeyLength) for i := 0; i < f.NumOps; i++ { key = nextKey(key) cha...
[ "func", "fillKeys", "(", "chans", "[", "]", "chan", "[", "]", "byte", ")", "{", "totalCap", ":=", "0", "\n", "for", "_", ",", "c", ":=", "range", "chans", "{", "totalCap", "+=", "cap", "(", "c", ")", "\n", "}", "\n", "if", "totalCap", "<", "f",...
// fills a bunch of channels round robin with keys
[ "fills", "a", "bunch", "of", "channels", "round", "robin", "with", "keys" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/client/cmd/setget/main.go#L80-L101
22,284
Netflix/rend
handlers/memcached/std/handler.go
NewHandler
func NewHandler(conn io.ReadWriteCloser) Handler { rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)) return Handler{ rw: rw, conn: conn, } }
go
func NewHandler(conn io.ReadWriteCloser) Handler { rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn)) return Handler{ rw: rw, conn: conn, } }
[ "func", "NewHandler", "(", "conn", "io", ".", "ReadWriteCloser", ")", "Handler", "{", "rw", ":=", "bufio", ".", "NewReadWriter", "(", "bufio", ".", "NewReader", "(", "conn", ")", ",", "bufio", ".", "NewWriter", "(", "conn", ")", ")", "\n", "return", "H...
// NewHandler returns an implementation of handlers.Handler that implements a straightforward // request-response like normal memcached usage.
[ "NewHandler", "returns", "an", "implementation", "of", "handlers", ".", "Handler", "that", "implements", "a", "straightforward", "request", "-", "response", "like", "normal", "memcached", "usage", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/std/handler.go#L49-L55
22,285
Netflix/rend
metrics/callbackgauges.go
RegisterIntGaugeCallback
func RegisterIntGaugeCallback(name string, tgs Tags, cb IntGaugeCallback) { id := atomic.AddUint32(curIntCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } intcallbacks[id] = cb intcbnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge intcbtags[id] = tgs }
go
func RegisterIntGaugeCallback(name string, tgs Tags, cb IntGaugeCallback) { id := atomic.AddUint32(curIntCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } intcallbacks[id] = cb intcbnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge intcbtags[id] = tgs }
[ "func", "RegisterIntGaugeCallback", "(", "name", "string", ",", "tgs", "Tags", ",", "cb", "IntGaugeCallback", ")", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curIntCbID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumCallbacks", "{", ...
// RegisterIntGaugeCallback registers a gauge callback which will be called every // time metrics are requested. // There is a maximum of 10240 int callbacks, after which adding a new one will panic.
[ "RegisterIntGaugeCallback", "registers", "a", "gauge", "callback", "which", "will", "be", "called", "every", "time", "metrics", "are", "requested", ".", "There", "is", "a", "maximum", "of", "10240", "int", "callbacks", "after", "which", "adding", "a", "new", "...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/callbackgauges.go#L44-L57
22,286
Netflix/rend
metrics/callbackgauges.go
RegisterFloatGaugeCallback
func RegisterFloatGaugeCallback(name string, tgs Tags, cb FloatGaugeCallback) { id := atomic.AddUint32(curFloatCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } floatcallbacks[id] = cb floatcbnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge floatcbtags[id] = tgs...
go
func RegisterFloatGaugeCallback(name string, tgs Tags, cb FloatGaugeCallback) { id := atomic.AddUint32(curFloatCbID, 1) - 1 if id >= maxNumCallbacks { panic("Too many callbacks") } floatcallbacks[id] = cb floatcbnames[id] = name tgs = copyTags(tgs) tgs[TagMetricType] = MetricTypeGauge floatcbtags[id] = tgs...
[ "func", "RegisterFloatGaugeCallback", "(", "name", "string", ",", "tgs", "Tags", ",", "cb", "FloatGaugeCallback", ")", "{", "id", ":=", "atomic", ".", "AddUint32", "(", "curFloatCbID", ",", "1", ")", "-", "1", "\n\n", "if", "id", ">=", "maxNumCallbacks", "...
// RegisterFloatGaugeCallback registers a gauge callback which will be called every // time metrics are requested. // There is a maximum of 10240 float callbacks, after which adding a new one will panic.
[ "RegisterFloatGaugeCallback", "registers", "a", "gauge", "callback", "which", "will", "be", "called", "every", "time", "metrics", "are", "requested", ".", "There", "is", "a", "maximum", "of", "10240", "float", "callbacks", "after", "which", "adding", "a", "new",...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/callbackgauges.go#L62-L75
22,287
Netflix/rend
client/stats/stats.go
Get
func Get(data []int) Stats { if len(data) == 0 { return Stats{} } min, max := minmax(data) return Stats{ Avg: avg(data) / msFactor, Min: min / msFactor, Max: max / msFactor, P50: p(data, 0.5) / msFactor, P75: p(data, 0.75) / msFactor, P90: p(data, 0.9) / msFactor, P95: p(data, 0.95) / msFactor, P...
go
func Get(data []int) Stats { if len(data) == 0 { return Stats{} } min, max := minmax(data) return Stats{ Avg: avg(data) / msFactor, Min: min / msFactor, Max: max / msFactor, P50: p(data, 0.5) / msFactor, P75: p(data, 0.75) / msFactor, P90: p(data, 0.9) / msFactor, P95: p(data, 0.95) / msFactor, P...
[ "func", "Get", "(", "data", "[", "]", "int", ")", "Stats", "{", "if", "len", "(", "data", ")", "==", "0", "{", "return", "Stats", "{", "}", "\n", "}", "\n", "min", ",", "max", ":=", "minmax", "(", "data", ")", "\n\n", "return", "Stats", "{", ...
// Accepts a sorted slice of durations in nanoseconds // Returns a Stats struct of millisecond statistics
[ "Accepts", "a", "sorted", "slice", "of", "durations", "in", "nanoseconds", "Returns", "a", "Stats", "struct", "of", "millisecond", "statistics" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/client/stats/stats.go#L35-L51
22,288
Netflix/rend
handlers/memcached/chunked/chunkedLimitedReader.go
Read
func (c chunkedLimitedReader) Read(p []byte) (n int, err error) { // If we've already read all our chunks and the remainders are <= 0, we're done if c.d.doneChunks >= c.d.numChunks || (c.d.remaining <= 0 && c.d.chunkRem <= 0) { return 0, io.EOF } // Data is done, returning only buffer bytes now if c.d.remaining...
go
func (c chunkedLimitedReader) Read(p []byte) (n int, err error) { // If we've already read all our chunks and the remainders are <= 0, we're done if c.d.doneChunks >= c.d.numChunks || (c.d.remaining <= 0 && c.d.chunkRem <= 0) { return 0, io.EOF } // Data is done, returning only buffer bytes now if c.d.remaining...
[ "func", "(", "c", "chunkedLimitedReader", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "// If we've already read all our chunks and the remainders are <= 0, we're done", "if", "c", ".", "d", ".", "doneChunks", ">=...
// io.Reader's interface implements this as a value method, not a pointer method.
[ "io", ".", "Reader", "s", "interface", "implements", "this", "as", "a", "value", "method", "not", "a", "pointer", "method", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/chunkedLimitedReader.go#L53-L89
22,289
Netflix/rend
handlers/memcached/chunked/handler.go
Add
func (h Handler) Add(cmd common.SetRequest) error { return h.handleSetCommon(cmd, common.RequestAdd) }
go
func (h Handler) Add(cmd common.SetRequest) error { return h.handleSetCommon(cmd, common.RequestAdd) }
[ "func", "(", "h", "Handler", ")", "Add", "(", "cmd", "common", ".", "SetRequest", ")", "error", "{", "return", "h", ".", "handleSetCommon", "(", "cmd", ",", "common", ".", "RequestAdd", ")", "\n", "}" ]
// Add performs an add request on the remote backend
[ "Add", "performs", "an", "add", "request", "on", "the", "remote", "backend" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L148-L150
22,290
Netflix/rend
handlers/memcached/chunked/handler.go
Replace
func (h Handler) Replace(cmd common.SetRequest) error { return h.handleSetCommon(cmd, common.RequestReplace) }
go
func (h Handler) Replace(cmd common.SetRequest) error { return h.handleSetCommon(cmd, common.RequestReplace) }
[ "func", "(", "h", "Handler", ")", "Replace", "(", "cmd", "common", ".", "SetRequest", ")", "error", "{", "return", "h", ".", "handleSetCommon", "(", "cmd", ",", "common", ".", "RequestReplace", ")", "\n", "}" ]
// Replace performs a replace request on the remote backend
[ "Replace", "performs", "a", "replace", "request", "on", "the", "remote", "backend" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L153-L155
22,291
Netflix/rend
handlers/memcached/chunked/handler.go
exptime
func exptime(ttl uint32) (exp uint32, expired bool) { // zero is the special forever case if ttl == 0 { return 0, false } now := uint32(time.Now().Unix()) // The memcached protocol has a... "quirk" where any expiration time over 30 // days is considered to be a unix timestamp. if ttl > realTimeMaxDelta { r...
go
func exptime(ttl uint32) (exp uint32, expired bool) { // zero is the special forever case if ttl == 0 { return 0, false } now := uint32(time.Now().Unix()) // The memcached protocol has a... "quirk" where any expiration time over 30 // days is considered to be a unix timestamp. if ttl > realTimeMaxDelta { r...
[ "func", "exptime", "(", "ttl", "uint32", ")", "(", "exp", "uint32", ",", "expired", "bool", ")", "{", "// zero is the special forever case", "if", "ttl", "==", "0", "{", "return", "0", ",", "false", "\n", "}", "\n\n", "now", ":=", "uint32", "(", "time", ...
// Takes a TTL in seconds and returns the unix time in seconds when the item will expire.
[ "Takes", "a", "TTL", "in", "seconds", "and", "returns", "the", "unix", "time", "in", "seconds", "when", "the", "item", "will", "expire", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L191-L207
22,292
Netflix/rend
handlers/memcached/chunked/handler.go
Append
func (h Handler) Append(cmd common.SetRequest) error { return h.handleAppendPrependCommon(cmd, common.RequestAppend) }
go
func (h Handler) Append(cmd common.SetRequest) error { return h.handleAppendPrependCommon(cmd, common.RequestAppend) }
[ "func", "(", "h", "Handler", ")", "Append", "(", "cmd", "common", ".", "SetRequest", ")", "error", "{", "return", "h", ".", "handleAppendPrependCommon", "(", "cmd", ",", "common", ".", "RequestAppend", ")", "\n", "}" ]
// Append performs an append request on the remote backend
[ "Append", "performs", "an", "append", "request", "on", "the", "remote", "backend" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L338-L340
22,293
Netflix/rend
handlers/memcached/chunked/handler.go
Prepend
func (h Handler) Prepend(cmd common.SetRequest) error { return h.handleAppendPrependCommon(cmd, common.RequestPrepend) }
go
func (h Handler) Prepend(cmd common.SetRequest) error { return h.handleAppendPrependCommon(cmd, common.RequestPrepend) }
[ "func", "(", "h", "Handler", ")", "Prepend", "(", "cmd", "common", ".", "SetRequest", ")", "error", "{", "return", "h", ".", "handleAppendPrependCommon", "(", "cmd", ",", "common", ".", "RequestPrepend", ")", "\n", "}" ]
// Prepend performs a prepend request on the remote backend
[ "Prepend", "performs", "a", "prepend", "request", "on", "the", "remote", "backend" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L343-L345
22,294
Netflix/rend
handlers/memcached/chunked/handler.go
Get
func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error) { // No buffering here so there's not multiple gets in memory dataOut := make(chan common.GetResponse) errorOut := make(chan error) go realHandleGet(cmd, dataOut, errorOut, h.rw) return dataOut, errorOut }
go
func (h Handler) Get(cmd common.GetRequest) (<-chan common.GetResponse, <-chan error) { // No buffering here so there's not multiple gets in memory dataOut := make(chan common.GetResponse) errorOut := make(chan error) go realHandleGet(cmd, dataOut, errorOut, h.rw) return dataOut, errorOut }
[ "func", "(", "h", "Handler", ")", "Get", "(", "cmd", "common", ".", "GetRequest", ")", "(", "<-", "chan", "common", ".", "GetResponse", ",", "<-", "chan", "error", ")", "{", "// No buffering here so there's not multiple gets in memory", "dataOut", ":=", "make", ...
// Get performs a batched get request on the remote backend. The channels returned // are expected to be read from until either a single error is received or the // response channel is exhausted.
[ "Get", "performs", "a", "batched", "get", "request", "on", "the", "remote", "backend", ".", "The", "channels", "returned", "are", "expected", "to", "be", "read", "from", "until", "either", "a", "single", "error", "is", "received", "or", "the", "response", ...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L468-L474
22,295
Netflix/rend
handlers/memcached/chunked/handler.go
GetE
func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) { // Being minimalist, not lazy. The chunked handler is not meant to be used with a // backing store that supports the GetE protocol extension. It would be a waste of // time and effort to support it here if it would "never" be u...
go
func (h Handler) GetE(cmd common.GetRequest) (<-chan common.GetEResponse, <-chan error) { // Being minimalist, not lazy. The chunked handler is not meant to be used with a // backing store that supports the GetE protocol extension. It would be a waste of // time and effort to support it here if it would "never" be u...
[ "func", "(", "h", "Handler", ")", "GetE", "(", "cmd", "common", ".", "GetRequest", ")", "(", "<-", "chan", "common", ".", "GetEResponse", ",", "<-", "chan", "error", ")", "{", "// Being minimalist, not lazy. The chunked handler is not meant to be used with a", "// b...
// GetE performs a batched gete request on the remote backend. The channels returned // are expected to be read from until either a single error is received or the // response channel is exhausted.
[ "GetE", "performs", "a", "batched", "gete", "request", "on", "the", "remote", "backend", ".", "The", "channels", "returned", "are", "expected", "to", "be", "read", "from", "until", "either", "a", "single", "error", "is", "received", "or", "the", "response", ...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/chunked/handler.go#L606-L618
22,296
Netflix/rend
metrics/counters.go
IncCounterBy
func IncCounterBy(id uint32, amount uint64) { atomic.AddUint64(&counters[id], amount) }
go
func IncCounterBy(id uint32, amount uint64) { atomic.AddUint64(&counters[id], amount) }
[ "func", "IncCounterBy", "(", "id", "uint32", ",", "amount", "uint64", ")", "{", "atomic", ".", "AddUint64", "(", "&", "counters", "[", "id", "]", ",", "amount", ")", "\n", "}" ]
// IncCounterBy increments the specified counter by the given amount. This is for situations // where the count is not a one by one thing, like counting bytes in and out of a system.
[ "IncCounterBy", "increments", "the", "specified", "counter", "by", "the", "given", "amount", ".", "This", "is", "for", "situations", "where", "the", "count", "is", "not", "a", "one", "by", "one", "thing", "like", "counting", "bytes", "in", "and", "out", "o...
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/metrics/counters.go#L66-L68
22,297
Netflix/rend
orcas/locked.go
getlock
func (l *LockedOrca) getlock(key []byte, read bool) sync.Locker { h := l.hpool.Get().(hash.Hash32) defer l.hpool.Put(h) h.Reset() // Calculate bucket using hash and mod. hash.Hash.Write() never returns an error. h.Write(key) bucket := int(h.Sum32()) bucket &= len(l.locks) - 1 //atomic.AddUint32(&l.counts[buck...
go
func (l *LockedOrca) getlock(key []byte, read bool) sync.Locker { h := l.hpool.Get().(hash.Hash32) defer l.hpool.Put(h) h.Reset() // Calculate bucket using hash and mod. hash.Hash.Write() never returns an error. h.Write(key) bucket := int(h.Sum32()) bucket &= len(l.locks) - 1 //atomic.AddUint32(&l.counts[buck...
[ "func", "(", "l", "*", "LockedOrca", ")", "getlock", "(", "key", "[", "]", "byte", ",", "read", "bool", ")", "sync", ".", "Locker", "{", "h", ":=", "l", ".", "hpool", ".", "Get", "(", ")", ".", "(", "hash", ".", "Hash32", ")", "\n", "defer", ...
//var numops uint64 = 0
[ "var", "numops", "uint64", "=", "0" ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/orcas/locked.go#L126-L149
22,298
Netflix/rend
handlers/memcached/batched/relay.go
getRelay
func getRelay(sock string, opts Opts) *relay { relayLock.RLock() if r, ok := relays[sock]; ok { relayLock.RUnlock() return r } relayLock.RUnlock() // Lock here because we are creating a new relay for the given socket path // The rest of the new connections will block here and then pick it up on // the doubl...
go
func getRelay(sock string, opts Opts) *relay { relayLock.RLock() if r, ok := relays[sock]; ok { relayLock.RUnlock() return r } relayLock.RUnlock() // Lock here because we are creating a new relay for the given socket path // The rest of the new connections will block here and then pick it up on // the doubl...
[ "func", "getRelay", "(", "sock", "string", ",", "opts", "Opts", ")", "*", "relay", "{", "relayLock", ".", "RLock", "(", ")", "\n", "if", "r", ",", "ok", ":=", "relays", "[", "sock", "]", ";", "ok", "{", "relayLock", ".", "RUnlock", "(", ")", "\n"...
// Creates a new relay with one connection or returns an existing relay for the // given socket.
[ "Creates", "a", "new", "relay", "with", "one", "connection", "or", "returns", "an", "existing", "relay", "for", "the", "given", "socket", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/relay.go#L53-L95
22,299
Netflix/rend
handlers/memcached/batched/relay.go
addConn
func (r *relay) addConn() { // Ensure there's no races when adding a connection r.addConnLock.Lock() defer r.addConnLock.Unlock() temp := r.conns.Load().([]*conn) connID := uint32(len(temp)) batchDelay := time.Duration(r.opts.BatchDelayMicros) * time.Microsecond poolconn := newConn(r.sock, connID, batchDelay, ...
go
func (r *relay) addConn() { // Ensure there's no races when adding a connection r.addConnLock.Lock() defer r.addConnLock.Unlock() temp := r.conns.Load().([]*conn) connID := uint32(len(temp)) batchDelay := time.Duration(r.opts.BatchDelayMicros) * time.Microsecond poolconn := newConn(r.sock, connID, batchDelay, ...
[ "func", "(", "r", "*", "relay", ")", "addConn", "(", ")", "{", "// Ensure there's no races when adding a connection", "r", ".", "addConnLock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "addConnLock", ".", "Unlock", "(", ")", "\n\n", "temp", ":=", "r"...
// Adds a connection to the pool. This is one way only, making this effectively // a high-water-mark pool with no connections being torn down.
[ "Adds", "a", "connection", "to", "the", "pool", ".", "This", "is", "one", "way", "only", "making", "this", "effectively", "a", "high", "-", "water", "-", "mark", "pool", "with", "no", "connections", "being", "torn", "down", "." ]
d3db570668d3ecd97cbdf0988c92145a9040e235
https://github.com/Netflix/rend/blob/d3db570668d3ecd97cbdf0988c92145a9040e235/handlers/memcached/batched/relay.go#L99-L115