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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
127,300 | spf13/cobra | doc/rest_docs.go | GenReSTTree | func GenReSTTree(cmd *cobra.Command, dir string) error {
emptyStr := func(s string) string { return "" }
return GenReSTTreeCustom(cmd, dir, emptyStr, defaultLinkHandler)
} | go | func GenReSTTree(cmd *cobra.Command, dir string) error {
emptyStr := func(s string) string { return "" }
return GenReSTTreeCustom(cmd, dir, emptyStr, defaultLinkHandler)
} | [
"func",
"GenReSTTree",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"dir",
"string",
")",
"error",
"{",
"emptyStr",
":=",
"func",
"(",
"s",
"string",
")",
"string",
"{",
"return",
"\"",
"\"",
"}",
"\n",
"return",
"GenReSTTreeCustom",
"(",
"cmd",
",",... | // GenReSTTree will generate a ReST page for this command and all
// descendants in the directory given.
// This function may not work correctly if your command names have `-` in them.
// If you have `cmd` with two subcmds, `sub` and `sub-third`,
// and `sub` has a subcommand called `third`, it is undefined which
// he... | [
"GenReSTTree",
"will",
"generate",
"a",
"ReST",
"page",
"for",
"this",
"command",
"and",
"all",
"descendants",
"in",
"the",
"directory",
"given",
".",
"This",
"function",
"may",
"not",
"work",
"correctly",
"if",
"your",
"command",
"names",
"have",
"-",
"in",... | 67fc4837d267bc9bfd6e47f77783fcc3dffc68de | https://github.com/spf13/cobra/blob/67fc4837d267bc9bfd6e47f77783fcc3dffc68de/doc/rest_docs.go#L137-L140 |
127,301 | spf13/cobra | cobra.go | AddTemplateFuncs | func AddTemplateFuncs(tmplFuncs template.FuncMap) {
for k, v := range tmplFuncs {
templateFuncs[k] = v
}
} | go | func AddTemplateFuncs(tmplFuncs template.FuncMap) {
for k, v := range tmplFuncs {
templateFuncs[k] = v
}
} | [
"func",
"AddTemplateFuncs",
"(",
"tmplFuncs",
"template",
".",
"FuncMap",
")",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"tmplFuncs",
"{",
"templateFuncs",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"}"
] | // AddTemplateFuncs adds multiple template functions that are available to Usage and
// Help template generation. | [
"AddTemplateFuncs",
"adds",
"multiple",
"template",
"functions",
"that",
"are",
"available",
"to",
"Usage",
"and",
"Help",
"template",
"generation",
"."
] | 67fc4837d267bc9bfd6e47f77783fcc3dffc68de | https://github.com/spf13/cobra/blob/67fc4837d267bc9bfd6e47f77783fcc3dffc68de/cobra.go#L74-L78 |
127,302 | spf13/cobra | cobra.go | Gt | func Gt(a interface{}, b interface{}) bool {
var left, right int64
av := reflect.ValueOf(a)
switch av.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
left = int64(av.Len())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
left = av.Int()
case reflect.String:... | go | func Gt(a interface{}, b interface{}) bool {
var left, right int64
av := reflect.ValueOf(a)
switch av.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
left = int64(av.Len())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
left = av.Int()
case reflect.String:... | [
"func",
"Gt",
"(",
"a",
"interface",
"{",
"}",
",",
"b",
"interface",
"{",
"}",
")",
"bool",
"{",
"var",
"left",
",",
"right",
"int64",
"\n",
"av",
":=",
"reflect",
".",
"ValueOf",
"(",
"a",
")",
"\n\n",
"switch",
"av",
".",
"Kind",
"(",
")",
"... | // FIXME Gt is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra.
// Gt takes two types and checks whether the first type is greater than the second. In case of types Arrays, Chans,
// Maps and Slices, Gt will compare their lengths. Ints are compared directly whi... | [
"FIXME",
"Gt",
"is",
"unused",
"by",
"cobra",
"and",
"should",
"be",
"removed",
"in",
"a",
"version",
"2",
".",
"It",
"exists",
"only",
"for",
"compatibility",
"with",
"users",
"of",
"cobra",
".",
"Gt",
"takes",
"two",
"types",
"and",
"checks",
"whether"... | 67fc4837d267bc9bfd6e47f77783fcc3dffc68de | https://github.com/spf13/cobra/blob/67fc4837d267bc9bfd6e47f77783fcc3dffc68de/cobra.go#L91-L116 |
127,303 | spf13/cobra | cobra.go | Eq | func Eq(a interface{}, b interface{}) bool {
av := reflect.ValueOf(a)
bv := reflect.ValueOf(b)
switch av.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
panic("Eq called on unsupported type")
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return av.Int() ==... | go | func Eq(a interface{}, b interface{}) bool {
av := reflect.ValueOf(a)
bv := reflect.ValueOf(b)
switch av.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
panic("Eq called on unsupported type")
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return av.Int() ==... | [
"func",
"Eq",
"(",
"a",
"interface",
"{",
"}",
",",
"b",
"interface",
"{",
"}",
")",
"bool",
"{",
"av",
":=",
"reflect",
".",
"ValueOf",
"(",
"a",
")",
"\n",
"bv",
":=",
"reflect",
".",
"ValueOf",
"(",
"b",
")",
"\n\n",
"switch",
"av",
".",
"Ki... | // FIXME Eq is unused by cobra and should be removed in a version 2. It exists only for compatibility with users of cobra.
// Eq takes two types and checks whether they are equal. Supported types are int and string. Unsupported types will panic. | [
"FIXME",
"Eq",
"is",
"unused",
"by",
"cobra",
"and",
"should",
"be",
"removed",
"in",
"a",
"version",
"2",
".",
"It",
"exists",
"only",
"for",
"compatibility",
"with",
"users",
"of",
"cobra",
".",
"Eq",
"takes",
"two",
"types",
"and",
"checks",
"whether"... | 67fc4837d267bc9bfd6e47f77783fcc3dffc68de | https://github.com/spf13/cobra/blob/67fc4837d267bc9bfd6e47f77783fcc3dffc68de/cobra.go#L121-L134 |
127,304 | spf13/cobra | cobra.go | ld | func ld(s, t string, ignoreCase bool) int {
if ignoreCase {
s = strings.ToLower(s)
t = strings.ToLower(t)
}
d := make([][]int, len(s)+1)
for i := range d {
d[i] = make([]int, len(t)+1)
}
for i := range d {
d[i][0] = i
}
for j := range d[0] {
d[0][j] = j
}
for j := 1; j <= len(t); j++ {
for i := 1;... | go | func ld(s, t string, ignoreCase bool) int {
if ignoreCase {
s = strings.ToLower(s)
t = strings.ToLower(t)
}
d := make([][]int, len(s)+1)
for i := range d {
d[i] = make([]int, len(t)+1)
}
for i := range d {
d[i][0] = i
}
for j := range d[0] {
d[0][j] = j
}
for j := 1; j <= len(t); j++ {
for i := 1;... | [
"func",
"ld",
"(",
"s",
",",
"t",
"string",
",",
"ignoreCase",
"bool",
")",
"int",
"{",
"if",
"ignoreCase",
"{",
"s",
"=",
"strings",
".",
"ToLower",
"(",
"s",
")",
"\n",
"t",
"=",
"strings",
".",
"ToLower",
"(",
"t",
")",
"\n",
"}",
"\n",
"d",... | // ld compares two strings and returns the levenshtein distance between them. | [
"ld",
"compares",
"two",
"strings",
"and",
"returns",
"the",
"levenshtein",
"distance",
"between",
"them",
"."
] | 67fc4837d267bc9bfd6e47f77783fcc3dffc68de | https://github.com/spf13/cobra/blob/67fc4837d267bc9bfd6e47f77783fcc3dffc68de/cobra.go#L165-L198 |
127,305 | nsqio/nsq | apps/to_nsq/to_nsq.go | readAndPublish | func readAndPublish(r *bufio.Reader, delim byte, producers map[string]*nsq.Producer) error {
line, readErr := r.ReadBytes(delim)
if len(line) > 0 {
// trim the delimiter
line = line[:len(line)-1]
}
if len(line) == 0 {
return readErr
}
for _, producer := range producers {
err := producer.Publish(*topic,... | go | func readAndPublish(r *bufio.Reader, delim byte, producers map[string]*nsq.Producer) error {
line, readErr := r.ReadBytes(delim)
if len(line) > 0 {
// trim the delimiter
line = line[:len(line)-1]
}
if len(line) == 0 {
return readErr
}
for _, producer := range producers {
err := producer.Publish(*topic,... | [
"func",
"readAndPublish",
"(",
"r",
"*",
"bufio",
".",
"Reader",
",",
"delim",
"byte",
",",
"producers",
"map",
"[",
"string",
"]",
"*",
"nsq",
".",
"Producer",
")",
"error",
"{",
"line",
",",
"readErr",
":=",
"r",
".",
"ReadBytes",
"(",
"delim",
")"... | // readAndPublish reads to the delim from r and publishes the bytes
// to the map of producers. | [
"readAndPublish",
"reads",
"to",
"the",
"delim",
"from",
"r",
"and",
"publishes",
"the",
"bytes",
"to",
"the",
"map",
"of",
"producers",
"."
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/apps/to_nsq/to_nsq.go#L128-L148 |
127,306 | nsqio/nsq | nsqlookupd/registration_db.go | AddRegistration | func (r *RegistrationDB) AddRegistration(k Registration) {
r.Lock()
defer r.Unlock()
_, ok := r.registrationMap[k]
if !ok {
r.registrationMap[k] = make(map[string]*Producer)
}
} | go | func (r *RegistrationDB) AddRegistration(k Registration) {
r.Lock()
defer r.Unlock()
_, ok := r.registrationMap[k]
if !ok {
r.registrationMap[k] = make(map[string]*Producer)
}
} | [
"func",
"(",
"r",
"*",
"RegistrationDB",
")",
"AddRegistration",
"(",
"k",
"Registration",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"r",
".",
"registrationMap",
"[",
"k",
"]",
... | // add a registration key | [
"add",
"a",
"registration",
"key"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqlookupd/registration_db.go#L62-L69 |
127,307 | nsqio/nsq | nsqlookupd/registration_db.go | AddProducer | func (r *RegistrationDB) AddProducer(k Registration, p *Producer) bool {
r.Lock()
defer r.Unlock()
_, ok := r.registrationMap[k]
if !ok {
r.registrationMap[k] = make(map[string]*Producer)
}
producers := r.registrationMap[k]
_, found := producers[p.peerInfo.id]
if found == false {
producers[p.peerInfo.id] = ... | go | func (r *RegistrationDB) AddProducer(k Registration, p *Producer) bool {
r.Lock()
defer r.Unlock()
_, ok := r.registrationMap[k]
if !ok {
r.registrationMap[k] = make(map[string]*Producer)
}
producers := r.registrationMap[k]
_, found := producers[p.peerInfo.id]
if found == false {
producers[p.peerInfo.id] = ... | [
"func",
"(",
"r",
"*",
"RegistrationDB",
")",
"AddProducer",
"(",
"k",
"Registration",
",",
"p",
"*",
"Producer",
")",
"bool",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"r",
".",
"... | // add a producer to a registration | [
"add",
"a",
"producer",
"to",
"a",
"registration"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqlookupd/registration_db.go#L72-L85 |
127,308 | nsqio/nsq | nsqlookupd/registration_db.go | RemoveProducer | func (r *RegistrationDB) RemoveProducer(k Registration, id string) (bool, int) {
r.Lock()
defer r.Unlock()
producers, ok := r.registrationMap[k]
if !ok {
return false, 0
}
removed := false
if _, exists := producers[id]; exists {
removed = true
}
// Note: this leaves keys in the DB even if they have empty ... | go | func (r *RegistrationDB) RemoveProducer(k Registration, id string) (bool, int) {
r.Lock()
defer r.Unlock()
producers, ok := r.registrationMap[k]
if !ok {
return false, 0
}
removed := false
if _, exists := producers[id]; exists {
removed = true
}
// Note: this leaves keys in the DB even if they have empty ... | [
"func",
"(",
"r",
"*",
"RegistrationDB",
")",
"RemoveProducer",
"(",
"k",
"Registration",
",",
"id",
"string",
")",
"(",
"bool",
",",
"int",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"producers",
",",
... | // remove a producer from a registration | [
"remove",
"a",
"producer",
"from",
"a",
"registration"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqlookupd/registration_db.go#L88-L103 |
127,309 | nsqio/nsq | nsqlookupd/registration_db.go | RemoveRegistration | func (r *RegistrationDB) RemoveRegistration(k Registration) {
r.Lock()
defer r.Unlock()
delete(r.registrationMap, k)
} | go | func (r *RegistrationDB) RemoveRegistration(k Registration) {
r.Lock()
defer r.Unlock()
delete(r.registrationMap, k)
} | [
"func",
"(",
"r",
"*",
"RegistrationDB",
")",
"RemoveRegistration",
"(",
"k",
"Registration",
")",
"{",
"r",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"r",
".",
"registrationMap",
",",
"k",
")",
"\n",
... | // remove a Registration and all it's producers | [
"remove",
"a",
"Registration",
"and",
"all",
"it",
"s",
"producers"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqlookupd/registration_db.go#L106-L110 |
127,310 | nsqio/nsq | nsqd/topic.go | getOrCreateChannel | func (t *Topic) getOrCreateChannel(channelName string) (*Channel, bool) {
channel, ok := t.channelMap[channelName]
if !ok {
deleteCallback := func(c *Channel) {
t.DeleteExistingChannel(c.name)
}
channel = NewChannel(t.name, channelName, t.ctx, deleteCallback)
t.channelMap[channelName] = channel
t.ctx.nsq... | go | func (t *Topic) getOrCreateChannel(channelName string) (*Channel, bool) {
channel, ok := t.channelMap[channelName]
if !ok {
deleteCallback := func(c *Channel) {
t.DeleteExistingChannel(c.name)
}
channel = NewChannel(t.name, channelName, t.ctx, deleteCallback)
t.channelMap[channelName] = channel
t.ctx.nsq... | [
"func",
"(",
"t",
"*",
"Topic",
")",
"getOrCreateChannel",
"(",
"channelName",
"string",
")",
"(",
"*",
"Channel",
",",
"bool",
")",
"{",
"channel",
",",
"ok",
":=",
"t",
".",
"channelMap",
"[",
"channelName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"delete... | // this expects the caller to handle locking | [
"this",
"expects",
"the",
"caller",
"to",
"handle",
"locking"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/topic.go#L120-L132 |
127,311 | nsqio/nsq | nsqd/topic.go | DeleteExistingChannel | func (t *Topic) DeleteExistingChannel(channelName string) error {
t.Lock()
channel, ok := t.channelMap[channelName]
if !ok {
t.Unlock()
return errors.New("channel does not exist")
}
delete(t.channelMap, channelName)
// not defered so that we can continue while the channel async closes
numChannels := len(t.ch... | go | func (t *Topic) DeleteExistingChannel(channelName string) error {
t.Lock()
channel, ok := t.channelMap[channelName]
if !ok {
t.Unlock()
return errors.New("channel does not exist")
}
delete(t.channelMap, channelName)
// not defered so that we can continue while the channel async closes
numChannels := len(t.ch... | [
"func",
"(",
"t",
"*",
"Topic",
")",
"DeleteExistingChannel",
"(",
"channelName",
"string",
")",
"error",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"channel",
",",
"ok",
":=",
"t",
".",
"channelMap",
"[",
"channelName",
"]",
"\n",
"if",
"!",
"ok",
"{",
... | // DeleteExistingChannel removes a channel from the topic only if it exists | [
"DeleteExistingChannel",
"removes",
"a",
"channel",
"from",
"the",
"topic",
"only",
"if",
"it",
"exists"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/topic.go#L145-L174 |
127,312 | nsqio/nsq | nsqd/topic.go | PutMessages | func (t *Topic) PutMessages(msgs []*Message) error {
t.RLock()
defer t.RUnlock()
if atomic.LoadInt32(&t.exitFlag) == 1 {
return errors.New("exiting")
}
messageTotalBytes := 0
for i, m := range msgs {
err := t.put(m)
if err != nil {
atomic.AddUint64(&t.messageCount, uint64(i))
atomic.AddUint64(&t.mes... | go | func (t *Topic) PutMessages(msgs []*Message) error {
t.RLock()
defer t.RUnlock()
if atomic.LoadInt32(&t.exitFlag) == 1 {
return errors.New("exiting")
}
messageTotalBytes := 0
for i, m := range msgs {
err := t.put(m)
if err != nil {
atomic.AddUint64(&t.messageCount, uint64(i))
atomic.AddUint64(&t.mes... | [
"func",
"(",
"t",
"*",
"Topic",
")",
"PutMessages",
"(",
"msgs",
"[",
"]",
"*",
"Message",
")",
"error",
"{",
"t",
".",
"RLock",
"(",
")",
"\n",
"defer",
"t",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"atomic",
".",
"LoadInt32",
"(",
"&",
"t",
".",... | // PutMessages writes multiple Messages to the queue | [
"PutMessages",
"writes",
"multiple",
"Messages",
"to",
"the",
"queue"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/topic.go#L193-L215 |
127,313 | nsqio/nsq | nsqd/topic.go | messagePump | func (t *Topic) messagePump() {
var msg *Message
var buf []byte
var err error
var chans []*Channel
var memoryMsgChan chan *Message
var backendChan chan []byte
// do not pass messages before Start(), but avoid blocking Pause() or GetChannel()
for {
select {
case <-t.channelUpdateChan:
continue
case <-t... | go | func (t *Topic) messagePump() {
var msg *Message
var buf []byte
var err error
var chans []*Channel
var memoryMsgChan chan *Message
var backendChan chan []byte
// do not pass messages before Start(), but avoid blocking Pause() or GetChannel()
for {
select {
case <-t.channelUpdateChan:
continue
case <-t... | [
"func",
"(",
"t",
"*",
"Topic",
")",
"messagePump",
"(",
")",
"{",
"var",
"msg",
"*",
"Message",
"\n",
"var",
"buf",
"[",
"]",
"byte",
"\n",
"var",
"err",
"error",
"\n",
"var",
"chans",
"[",
"]",
"*",
"Channel",
"\n",
"var",
"memoryMsgChan",
"chan"... | // messagePump selects over the in-memory and backend queue and
// writes messages to every channel for this topic | [
"messagePump",
"selects",
"over",
"the",
"in",
"-",
"memory",
"and",
"backend",
"queue",
"and",
"writes",
"messages",
"to",
"every",
"channel",
"for",
"this",
"topic"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/topic.go#L241-L336 |
127,314 | nsqio/nsq | internal/clusterinfo/data.go | GetLookupdProducers | func (c *ClusterInfo) GetLookupdProducers(lookupdHTTPAddrs []string) (Producers, error) {
var producers []*Producer
var lock sync.Mutex
var wg sync.WaitGroup
var errs []error
producersByAddr := make(map[string]*Producer)
maxVersion, _ := semver.Parse("0.0.0")
type respType struct {
Producers []*Producer `jso... | go | func (c *ClusterInfo) GetLookupdProducers(lookupdHTTPAddrs []string) (Producers, error) {
var producers []*Producer
var lock sync.Mutex
var wg sync.WaitGroup
var errs []error
producersByAddr := make(map[string]*Producer)
maxVersion, _ := semver.Parse("0.0.0")
type respType struct {
Producers []*Producer `jso... | [
"func",
"(",
"c",
"*",
"ClusterInfo",
")",
"GetLookupdProducers",
"(",
"lookupdHTTPAddrs",
"[",
"]",
"string",
")",
"(",
"Producers",
",",
"error",
")",
"{",
"var",
"producers",
"[",
"]",
"*",
"Producer",
"\n",
"var",
"lock",
"sync",
".",
"Mutex",
"\n",
... | // GetLookupdProducers returns Producers of all the nsqd connected to the given lookupds | [
"GetLookupdProducers",
"returns",
"Producers",
"of",
"all",
"the",
"nsqd",
"connected",
"to",
"the",
"given",
"lookupds"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/clusterinfo/data.go#L170-L236 |
127,315 | nsqio/nsq | internal/clusterinfo/data.go | GetLookupdTopicProducers | func (c *ClusterInfo) GetLookupdTopicProducers(topic string, lookupdHTTPAddrs []string) (Producers, error) {
var producers Producers
var lock sync.Mutex
var wg sync.WaitGroup
var errs []error
type respType struct {
Producers Producers `json:"producers"`
}
for _, addr := range lookupdHTTPAddrs {
wg.Add(1)
... | go | func (c *ClusterInfo) GetLookupdTopicProducers(topic string, lookupdHTTPAddrs []string) (Producers, error) {
var producers Producers
var lock sync.Mutex
var wg sync.WaitGroup
var errs []error
type respType struct {
Producers Producers `json:"producers"`
}
for _, addr := range lookupdHTTPAddrs {
wg.Add(1)
... | [
"func",
"(",
"c",
"*",
"ClusterInfo",
")",
"GetLookupdTopicProducers",
"(",
"topic",
"string",
",",
"lookupdHTTPAddrs",
"[",
"]",
"string",
")",
"(",
"Producers",
",",
"error",
")",
"{",
"var",
"producers",
"Producers",
"\n",
"var",
"lock",
"sync",
".",
"M... | // GetLookupdTopicProducers returns Producers of all the nsqd for a given topic by
// unioning the nodes returned from the given lookupd | [
"GetLookupdTopicProducers",
"returns",
"Producers",
"of",
"all",
"the",
"nsqd",
"for",
"a",
"given",
"topic",
"by",
"unioning",
"the",
"nodes",
"returned",
"from",
"the",
"given",
"lookupd"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/clusterinfo/data.go#L240-L289 |
127,316 | nsqio/nsq | internal/clusterinfo/data.go | GetNSQDProducers | func (c *ClusterInfo) GetNSQDProducers(nsqdHTTPAddrs []string) (Producers, error) {
var producers Producers
var lock sync.Mutex
var wg sync.WaitGroup
var errs []error
type infoRespType struct {
Version string `json:"version"`
BroadcastAddress string `json:"broadcast_address"`
Hostname strin... | go | func (c *ClusterInfo) GetNSQDProducers(nsqdHTTPAddrs []string) (Producers, error) {
var producers Producers
var lock sync.Mutex
var wg sync.WaitGroup
var errs []error
type infoRespType struct {
Version string `json:"version"`
BroadcastAddress string `json:"broadcast_address"`
Hostname strin... | [
"func",
"(",
"c",
"*",
"ClusterInfo",
")",
"GetNSQDProducers",
"(",
"nsqdHTTPAddrs",
"[",
"]",
"string",
")",
"(",
"Producers",
",",
"error",
")",
"{",
"var",
"producers",
"Producers",
"\n",
"var",
"lock",
"sync",
".",
"Mutex",
"\n",
"var",
"wg",
"sync",... | // GetNSQDProducers returns Producers of all the given nsqd | [
"GetNSQDProducers",
"returns",
"Producers",
"of",
"all",
"the",
"given",
"nsqd"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/clusterinfo/data.go#L343-L424 |
127,317 | nsqio/nsq | internal/clusterinfo/data.go | TombstoneNodeForTopic | func (c *ClusterInfo) TombstoneNodeForTopic(topic string, node string, lookupdHTTPAddrs []string) error {
var errs []error
// tombstone the topic on all the lookupds
qs := fmt.Sprintf("topic=%s&node=%s", url.QueryEscape(topic), url.QueryEscape(node))
err := c.nsqlookupdPOST(lookupdHTTPAddrs, "topic/tombstone", qs)... | go | func (c *ClusterInfo) TombstoneNodeForTopic(topic string, node string, lookupdHTTPAddrs []string) error {
var errs []error
// tombstone the topic on all the lookupds
qs := fmt.Sprintf("topic=%s&node=%s", url.QueryEscape(topic), url.QueryEscape(node))
err := c.nsqlookupdPOST(lookupdHTTPAddrs, "topic/tombstone", qs)... | [
"func",
"(",
"c",
"*",
"ClusterInfo",
")",
"TombstoneNodeForTopic",
"(",
"topic",
"string",
",",
"node",
"string",
",",
"lookupdHTTPAddrs",
"[",
"]",
"string",
")",
"error",
"{",
"var",
"errs",
"[",
"]",
"error",
"\n\n",
"// tombstone the topic on all the lookup... | // TombstoneNodeForTopic tombstones the given node for the given topic on all the given nsqlookupd
// and deletes the topic from the node | [
"TombstoneNodeForTopic",
"tombstones",
"the",
"given",
"node",
"for",
"the",
"given",
"topic",
"on",
"all",
"the",
"given",
"nsqlookupd",
"and",
"deletes",
"the",
"topic",
"from",
"the",
"node"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/clusterinfo/data.go#L632-L670 |
127,318 | nsqio/nsq | nsqd/lookup_peer.go | Connect | func (lp *lookupPeer) Connect() error {
lp.logf(lg.INFO, "LOOKUP connecting to %s", lp.addr)
conn, err := net.DialTimeout("tcp", lp.addr, time.Second)
if err != nil {
return err
}
lp.conn = conn
return nil
} | go | func (lp *lookupPeer) Connect() error {
lp.logf(lg.INFO, "LOOKUP connecting to %s", lp.addr)
conn, err := net.DialTimeout("tcp", lp.addr, time.Second)
if err != nil {
return err
}
lp.conn = conn
return nil
} | [
"func",
"(",
"lp",
"*",
"lookupPeer",
")",
"Connect",
"(",
")",
"error",
"{",
"lp",
".",
"logf",
"(",
"lg",
".",
"INFO",
",",
"\"",
"\"",
",",
"lp",
".",
"addr",
")",
"\n",
"conn",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
... | // Connect will Dial the specified address, with timeouts | [
"Connect",
"will",
"Dial",
"the",
"specified",
"address",
"with",
"timeouts"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/lookup_peer.go#L51-L59 |
127,319 | nsqio/nsq | nsqd/lookup_peer.go | Read | func (lp *lookupPeer) Read(data []byte) (int, error) {
lp.conn.SetReadDeadline(time.Now().Add(time.Second))
return lp.conn.Read(data)
} | go | func (lp *lookupPeer) Read(data []byte) (int, error) {
lp.conn.SetReadDeadline(time.Now().Add(time.Second))
return lp.conn.Read(data)
} | [
"func",
"(",
"lp",
"*",
"lookupPeer",
")",
"Read",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"lp",
".",
"conn",
".",
"SetReadDeadline",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"time",
".",
"Second",
")"... | // Read implements the io.Reader interface, adding deadlines | [
"Read",
"implements",
"the",
"io",
".",
"Reader",
"interface",
"adding",
"deadlines"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/lookup_peer.go#L67-L70 |
127,320 | nsqio/nsq | nsqd/lookup_peer.go | Write | func (lp *lookupPeer) Write(data []byte) (int, error) {
lp.conn.SetWriteDeadline(time.Now().Add(time.Second))
return lp.conn.Write(data)
} | go | func (lp *lookupPeer) Write(data []byte) (int, error) {
lp.conn.SetWriteDeadline(time.Now().Add(time.Second))
return lp.conn.Write(data)
} | [
"func",
"(",
"lp",
"*",
"lookupPeer",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"lp",
".",
"conn",
".",
"SetWriteDeadline",
"(",
"time",
".",
"Now",
"(",
")",
".",
"Add",
"(",
"time",
".",
"Second",
"... | // Write implements the io.Writer interface, adding deadlines | [
"Write",
"implements",
"the",
"io",
".",
"Writer",
"interface",
"adding",
"deadlines"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/lookup_peer.go#L73-L76 |
127,321 | nsqio/nsq | nsqd/nsqd.go | GetExistingTopic | func (n *NSQD) GetExistingTopic(topicName string) (*Topic, error) {
n.RLock()
defer n.RUnlock()
topic, ok := n.topicMap[topicName]
if !ok {
return nil, errors.New("topic does not exist")
}
return topic, nil
} | go | func (n *NSQD) GetExistingTopic(topicName string) (*Topic, error) {
n.RLock()
defer n.RUnlock()
topic, ok := n.topicMap[topicName]
if !ok {
return nil, errors.New("topic does not exist")
}
return topic, nil
} | [
"func",
"(",
"n",
"*",
"NSQD",
")",
"GetExistingTopic",
"(",
"topicName",
"string",
")",
"(",
"*",
"Topic",
",",
"error",
")",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"RUnlock",
"(",
")",
"\n",
"topic",
",",
"ok",
":=",
"n",
... | // GetExistingTopic gets a topic only if it exists | [
"GetExistingTopic",
"gets",
"a",
"topic",
"only",
"if",
"it",
"exists"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/nsqd.go#L511-L519 |
127,322 | nsqio/nsq | nsqd/nsqd.go | DeleteExistingTopic | func (n *NSQD) DeleteExistingTopic(topicName string) error {
n.RLock()
topic, ok := n.topicMap[topicName]
if !ok {
n.RUnlock()
return errors.New("topic does not exist")
}
n.RUnlock()
// delete empties all channels and the topic itself before closing
// (so that we dont leave any messages around)
//
// we ... | go | func (n *NSQD) DeleteExistingTopic(topicName string) error {
n.RLock()
topic, ok := n.topicMap[topicName]
if !ok {
n.RUnlock()
return errors.New("topic does not exist")
}
n.RUnlock()
// delete empties all channels and the topic itself before closing
// (so that we dont leave any messages around)
//
// we ... | [
"func",
"(",
"n",
"*",
"NSQD",
")",
"DeleteExistingTopic",
"(",
"topicName",
"string",
")",
"error",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"topic",
",",
"ok",
":=",
"n",
".",
"topicMap",
"[",
"topicName",
"]",
"\n",
"if",
"!",
"ok",
"{",
"n",
"... | // DeleteExistingTopic removes a topic only if it exists | [
"DeleteExistingTopic",
"removes",
"a",
"topic",
"only",
"if",
"it",
"exists"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/nsqd.go#L522-L544 |
127,323 | nsqio/nsq | nsqd/nsqd.go | channels | func (n *NSQD) channels() []*Channel {
var channels []*Channel
n.RLock()
for _, t := range n.topicMap {
t.RLock()
for _, c := range t.channelMap {
channels = append(channels, c)
}
t.RUnlock()
}
n.RUnlock()
return channels
} | go | func (n *NSQD) channels() []*Channel {
var channels []*Channel
n.RLock()
for _, t := range n.topicMap {
t.RLock()
for _, c := range t.channelMap {
channels = append(channels, c)
}
t.RUnlock()
}
n.RUnlock()
return channels
} | [
"func",
"(",
"n",
"*",
"NSQD",
")",
"channels",
"(",
")",
"[",
"]",
"*",
"Channel",
"{",
"var",
"channels",
"[",
"]",
"*",
"Channel",
"\n",
"n",
".",
"RLock",
"(",
")",
"\n",
"for",
"_",
",",
"t",
":=",
"range",
"n",
".",
"topicMap",
"{",
"t"... | // channels returns a flat slice of all channels in all topics | [
"channels",
"returns",
"a",
"flat",
"slice",
"of",
"all",
"channels",
"in",
"all",
"topics"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/nsqd.go#L571-L583 |
127,324 | nsqio/nsq | internal/quantile/aggregate.go | Add | func (e *E2eProcessingLatencyAggregate) Add(e2 *E2eProcessingLatencyAggregate) {
e.Addr = "*"
p := e.Percentiles
e.Count += e2.Count
for _, value := range e2.Percentiles {
i := -1
for j, v := range p {
if value["quantile"] == v["quantile"] {
i = j
break
}
}
if i == -1 {
i = len(p)
e.Perc... | go | func (e *E2eProcessingLatencyAggregate) Add(e2 *E2eProcessingLatencyAggregate) {
e.Addr = "*"
p := e.Percentiles
e.Count += e2.Count
for _, value := range e2.Percentiles {
i := -1
for j, v := range p {
if value["quantile"] == v["quantile"] {
i = j
break
}
}
if i == -1 {
i = len(p)
e.Perc... | [
"func",
"(",
"e",
"*",
"E2eProcessingLatencyAggregate",
")",
"Add",
"(",
"e2",
"*",
"E2eProcessingLatencyAggregate",
")",
"{",
"e",
".",
"Addr",
"=",
"\"",
"\"",
"\n",
"p",
":=",
"e",
".",
"Percentiles",
"\n",
"e",
".",
"Count",
"+=",
"e2",
".",
"Count... | // Add merges e2 into e by averaging the percentiles | [
"Add",
"merges",
"e2",
"into",
"e",
"by",
"averaging",
"the",
"percentiles"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/quantile/aggregate.go#L55-L85 |
127,325 | nsqio/nsq | nsqlookupd/nsqlookupd.go | Main | func (l *NSQLookupd) Main() error {
ctx := &Context{l}
exitCh := make(chan error)
var once sync.Once
exitFunc := func(err error) {
once.Do(func() {
if err != nil {
l.logf(LOG_FATAL, "%s", err)
}
exitCh <- err
})
}
tcpServer := &tcpServer{ctx: ctx}
l.waitGroup.Wrap(func() {
exitFunc(protocol.... | go | func (l *NSQLookupd) Main() error {
ctx := &Context{l}
exitCh := make(chan error)
var once sync.Once
exitFunc := func(err error) {
once.Do(func() {
if err != nil {
l.logf(LOG_FATAL, "%s", err)
}
exitCh <- err
})
}
tcpServer := &tcpServer{ctx: ctx}
l.waitGroup.Wrap(func() {
exitFunc(protocol.... | [
"func",
"(",
"l",
"*",
"NSQLookupd",
")",
"Main",
"(",
")",
"error",
"{",
"ctx",
":=",
"&",
"Context",
"{",
"l",
"}",
"\n\n",
"exitCh",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"var",
"once",
"sync",
".",
"Once",
"\n",
"exitFunc",
":=",
"fu... | // Main starts an instance of nsqlookupd and returns an
// error if there was a problem starting up. | [
"Main",
"starts",
"an",
"instance",
"of",
"nsqlookupd",
"and",
"returns",
"an",
"error",
"if",
"there",
"was",
"a",
"problem",
"starting",
"up",
"."
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqlookupd/nsqlookupd.go#L52-L77 |
127,326 | nsqio/nsq | internal/http_api/compress.go | CompressHandler | func CompressHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
L:
for _, enc := range strings.Split(r.Header.Get("Accept-Encoding"), ",") {
switch strings.TrimSpace(enc) {
case "gzip":
w.Header().Set("Content-Encoding", "gzip")
w.Header().Add... | go | func CompressHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
L:
for _, enc := range strings.Split(r.Header.Get("Accept-Encoding"), ",") {
switch strings.TrimSpace(enc) {
case "gzip":
w.Header().Set("Content-Encoding", "gzip")
w.Header().Add... | [
"func",
"CompressHandler",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"L",
":",
"for... | // CompressHandler gzip compresses HTTP responses for clients that support it
// via the 'Accept-Encoding' header. | [
"CompressHandler",
"gzip",
"compresses",
"HTTP",
"responses",
"for",
"clients",
"that",
"support",
"it",
"via",
"the",
"Accept",
"-",
"Encoding",
"header",
"."
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/http_api/compress.go#L43-L91 |
127,327 | nsqio/nsq | nsqadmin/http.go | NewSingleHostReverseProxy | func NewSingleHostReverseProxy(target *url.URL, connectTimeout time.Duration, requestTimeout time.Duration) *httputil.ReverseProxy {
director := func(req *http.Request) {
req.URL.Scheme = target.Scheme
req.URL.Host = target.Host
if target.User != nil {
passwd, _ := target.User.Password()
req.SetBasicAuth(t... | go | func NewSingleHostReverseProxy(target *url.URL, connectTimeout time.Duration, requestTimeout time.Duration) *httputil.ReverseProxy {
director := func(req *http.Request) {
req.URL.Scheme = target.Scheme
req.URL.Host = target.Host
if target.User != nil {
passwd, _ := target.User.Password()
req.SetBasicAuth(t... | [
"func",
"NewSingleHostReverseProxy",
"(",
"target",
"*",
"url",
".",
"URL",
",",
"connectTimeout",
"time",
".",
"Duration",
",",
"requestTimeout",
"time",
".",
"Duration",
")",
"*",
"httputil",
".",
"ReverseProxy",
"{",
"director",
":=",
"func",
"(",
"req",
... | // this is similar to httputil.NewSingleHostReverseProxy except it passes along basic auth | [
"this",
"is",
"similar",
"to",
"httputil",
".",
"NewSingleHostReverseProxy",
"except",
"it",
"passes",
"along",
"basic",
"auth"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqadmin/http.go#L35-L48 |
127,328 | nsqio/nsq | apps/nsqd/options.go | Validate | func (cfg config) Validate() {
// special validation/translation
if v, exists := cfg["tls_required"]; exists {
var t tlsRequiredOption
err := t.Set(fmt.Sprintf("%v", v))
if err == nil {
cfg["tls_required"] = t.String()
} else {
logFatal("failed parsing tls_required %+v", v)
}
}
if v, exists := cfg["... | go | func (cfg config) Validate() {
// special validation/translation
if v, exists := cfg["tls_required"]; exists {
var t tlsRequiredOption
err := t.Set(fmt.Sprintf("%v", v))
if err == nil {
cfg["tls_required"] = t.String()
} else {
logFatal("failed parsing tls_required %+v", v)
}
}
if v, exists := cfg["... | [
"func",
"(",
"cfg",
"config",
")",
"Validate",
"(",
")",
"{",
"// special validation/translation",
"if",
"v",
",",
"exists",
":=",
"cfg",
"[",
"\"",
"\"",
"]",
";",
"exists",
"{",
"var",
"t",
"tlsRequiredOption",
"\n",
"err",
":=",
"t",
".",
"Set",
"("... | // Validate settings in the config file, and fatal on errors | [
"Validate",
"settings",
"in",
"the",
"config",
"file",
"and",
"fatal",
"on",
"errors"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/apps/nsqd/options.go#L69-L94 |
127,329 | nsqio/nsq | nsqd/protocol_v2.go | getMessageID | func getMessageID(p []byte) (*MessageID, error) {
if len(p) != MsgIDLength {
return nil, errors.New("Invalid Message ID")
}
return (*MessageID)(unsafe.Pointer(&p[0])), nil
} | go | func getMessageID(p []byte) (*MessageID, error) {
if len(p) != MsgIDLength {
return nil, errors.New("Invalid Message ID")
}
return (*MessageID)(unsafe.Pointer(&p[0])), nil
} | [
"func",
"getMessageID",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"*",
"MessageID",
",",
"error",
")",
"{",
"if",
"len",
"(",
"p",
")",
"!=",
"MsgIDLength",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"re... | // validate and cast the bytes on the wire to a message ID | [
"validate",
"and",
"cast",
"the",
"bytes",
"on",
"the",
"wire",
"to",
"a",
"message",
"ID"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/protocol_v2.go#L1001-L1006 |
127,330 | nsqio/nsq | internal/http_api/api_request.go | NewDeadlineTransport | func NewDeadlineTransport(connectTimeout time.Duration, requestTimeout time.Duration) *http.Transport {
// arbitrary values copied from http.DefaultTransport
transport := &http.Transport{
DialContext: (&net.Dialer{
Timeout: connectTimeout,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
... | go | func NewDeadlineTransport(connectTimeout time.Duration, requestTimeout time.Duration) *http.Transport {
// arbitrary values copied from http.DefaultTransport
transport := &http.Transport{
DialContext: (&net.Dialer{
Timeout: connectTimeout,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
... | [
"func",
"NewDeadlineTransport",
"(",
"connectTimeout",
"time",
".",
"Duration",
",",
"requestTimeout",
"time",
".",
"Duration",
")",
"*",
"http",
".",
"Transport",
"{",
"// arbitrary values copied from http.DefaultTransport",
"transport",
":=",
"&",
"http",
".",
"Tran... | // A custom http.Transport with support for deadline timeouts | [
"A",
"custom",
"http",
".",
"Transport",
"with",
"support",
"for",
"deadline",
"timeouts"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/http_api/api_request.go#L17-L31 |
127,331 | nsqio/nsq | internal/http_api/api_request.go | GETV1 | func (c *Client) GETV1(endpoint string, v interface{}) error {
retry:
req, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
return err
}
req.Header.Add("Accept", "application/vnd.nsq; version=1.0")
resp, err := c.c.Do(req)
if err != nil {
return err
}
body, err := ioutil.ReadAll(resp.Body)
r... | go | func (c *Client) GETV1(endpoint string, v interface{}) error {
retry:
req, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
return err
}
req.Header.Add("Accept", "application/vnd.nsq; version=1.0")
resp, err := c.c.Do(req)
if err != nil {
return err
}
body, err := ioutil.ReadAll(resp.Body)
r... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GETV1",
"(",
"endpoint",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"retry",
":",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"endpoint",
",",
"nil",
")",
"\n... | // GETV1 is a helper function to perform a V1 HTTP request
// and parse our NSQ daemon's expected response format, with deadlines. | [
"GETV1",
"is",
"a",
"helper",
"function",
"to",
"perform",
"a",
"V1",
"HTTP",
"request",
"and",
"parse",
"our",
"NSQ",
"daemon",
"s",
"expected",
"response",
"format",
"with",
"deadlines",
"."
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/http_api/api_request.go#L50-L85 |
127,332 | nsqio/nsq | internal/protocol/protocol.go | SendResponse | func SendResponse(w io.Writer, data []byte) (int, error) {
err := binary.Write(w, binary.BigEndian, int32(len(data)))
if err != nil {
return 0, err
}
n, err := w.Write(data)
if err != nil {
return 0, err
}
return (n + 4), nil
} | go | func SendResponse(w io.Writer, data []byte) (int, error) {
err := binary.Write(w, binary.BigEndian, int32(len(data)))
if err != nil {
return 0, err
}
n, err := w.Write(data)
if err != nil {
return 0, err
}
return (n + 4), nil
} | [
"func",
"SendResponse",
"(",
"w",
"io",
".",
"Writer",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"err",
":=",
"binary",
".",
"Write",
"(",
"w",
",",
"binary",
".",
"BigEndian",
",",
"int32",
"(",
"len",
"(",
"data",
... | // SendResponse is a server side utility function to prefix data with a length header
// and write to the supplied Writer | [
"SendResponse",
"is",
"a",
"server",
"side",
"utility",
"function",
"to",
"prefix",
"data",
"with",
"a",
"length",
"header",
"and",
"write",
"to",
"the",
"supplied",
"Writer"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/protocol/protocol.go#L16-L28 |
127,333 | nsqio/nsq | internal/protocol/protocol.go | SendFramedResponse | func SendFramedResponse(w io.Writer, frameType int32, data []byte) (int, error) {
beBuf := make([]byte, 4)
size := uint32(len(data)) + 4
binary.BigEndian.PutUint32(beBuf, size)
n, err := w.Write(beBuf)
if err != nil {
return n, err
}
binary.BigEndian.PutUint32(beBuf, uint32(frameType))
n, err = w.Write(beBu... | go | func SendFramedResponse(w io.Writer, frameType int32, data []byte) (int, error) {
beBuf := make([]byte, 4)
size := uint32(len(data)) + 4
binary.BigEndian.PutUint32(beBuf, size)
n, err := w.Write(beBuf)
if err != nil {
return n, err
}
binary.BigEndian.PutUint32(beBuf, uint32(frameType))
n, err = w.Write(beBu... | [
"func",
"SendFramedResponse",
"(",
"w",
"io",
".",
"Writer",
",",
"frameType",
"int32",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"beBuf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"size",
":=",
"uint... | // SendFramedResponse is a server side utility function to prefix data with a length header
// and frame header and write to the supplied Writer | [
"SendFramedResponse",
"is",
"a",
"server",
"side",
"utility",
"function",
"to",
"prefix",
"data",
"with",
"a",
"length",
"header",
"and",
"frame",
"header",
"and",
"write",
"to",
"the",
"supplied",
"Writer"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/protocol/protocol.go#L32-L50 |
127,334 | nsqio/nsq | internal/clusterinfo/types.go | UnmarshalJSON | func (p *Producer) UnmarshalJSON(b []byte) error {
var r struct {
RemoteAddress string `json:"remote_address"`
Hostname string `json:"hostname"`
BroadcastAddress string `json:"broadcast_address"`
TCPPort int `json:"tcp_port"`
HTTPPort int `json:"http_port"`
Versi... | go | func (p *Producer) UnmarshalJSON(b []byte) error {
var r struct {
RemoteAddress string `json:"remote_address"`
Hostname string `json:"hostname"`
BroadcastAddress string `json:"broadcast_address"`
TCPPort int `json:"tcp_port"`
HTTPPort int `json:"http_port"`
Versi... | [
"func",
"(",
"p",
"*",
"Producer",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"r",
"struct",
"{",
"RemoteAddress",
"string",
"`json:\"remote_address\"`",
"\n",
"Hostname",
"string",
"`json:\"hostname\"`",
"\n",
"BroadcastAddress"... | // UnmarshalJSON implements json.Unmarshaler and postprocesses of ProducerTopics and VersionObj | [
"UnmarshalJSON",
"implements",
"json",
".",
"Unmarshaler",
"and",
"postprocesses",
"of",
"ProducerTopics",
"and",
"VersionObj"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/clusterinfo/types.go#L39-L70 |
127,335 | nsqio/nsq | internal/clusterinfo/types.go | UnmarshalJSON | func (s *ClientStats) UnmarshalJSON(b []byte) error {
type locaClientStats ClientStats // re-typed to prevent recursion from json.Unmarshal
var ss locaClientStats
if err := json.Unmarshal(b, &ss); err != nil {
return err
}
*s = ClientStats(ss)
s.ConnectedDuration = time.Now().Truncate(time.Second).Sub(time.Unix... | go | func (s *ClientStats) UnmarshalJSON(b []byte) error {
type locaClientStats ClientStats // re-typed to prevent recursion from json.Unmarshal
var ss locaClientStats
if err := json.Unmarshal(b, &ss); err != nil {
return err
}
*s = ClientStats(ss)
s.ConnectedDuration = time.Now().Truncate(time.Second).Sub(time.Unix... | [
"func",
"(",
"s",
"*",
"ClientStats",
")",
"UnmarshalJSON",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"type",
"locaClientStats",
"ClientStats",
"// re-typed to prevent recursion from json.Unmarshal",
"\n",
"var",
"ss",
"locaClientStats",
"\n",
"if",
"err",
":... | // UnmarshalJSON implements json.Unmarshaler and postprocesses ConnectedDuration | [
"UnmarshalJSON",
"implements",
"json",
".",
"Unmarshaler",
"and",
"postprocesses",
"ConnectedDuration"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/internal/clusterinfo/types.go#L220-L229 |
127,336 | nsqio/nsq | nsqd/channel.go | NewChannel | func NewChannel(topicName string, channelName string, ctx *context,
deleteCallback func(*Channel)) *Channel {
c := &Channel{
topicName: topicName,
name: channelName,
memoryMsgChan: make(chan *Message, ctx.nsqd.getOpts().MemQueueSize),
clients: make(map[int64]Consumer),
deleteCallback... | go | func NewChannel(topicName string, channelName string, ctx *context,
deleteCallback func(*Channel)) *Channel {
c := &Channel{
topicName: topicName,
name: channelName,
memoryMsgChan: make(chan *Message, ctx.nsqd.getOpts().MemQueueSize),
clients: make(map[int64]Consumer),
deleteCallback... | [
"func",
"NewChannel",
"(",
"topicName",
"string",
",",
"channelName",
"string",
",",
"ctx",
"*",
"context",
",",
"deleteCallback",
"func",
"(",
"*",
"Channel",
")",
")",
"*",
"Channel",
"{",
"c",
":=",
"&",
"Channel",
"{",
"topicName",
":",
"topicName",
... | // NewChannel creates a new instance of the Channel type and returns a pointer | [
"NewChannel",
"creates",
"a",
"new",
"instance",
"of",
"the",
"Channel",
"type",
"and",
"returns",
"a",
"pointer"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L74-L119 |
127,337 | nsqio/nsq | nsqd/channel.go | TouchMessage | func (c *Channel) TouchMessage(clientID int64, id MessageID, clientMsgTimeout time.Duration) error {
msg, err := c.popInFlightMessage(clientID, id)
if err != nil {
return err
}
c.removeFromInFlightPQ(msg)
newTimeout := time.Now().Add(clientMsgTimeout)
if newTimeout.Sub(msg.deliveryTS) >=
c.ctx.nsqd.getOpts()... | go | func (c *Channel) TouchMessage(clientID int64, id MessageID, clientMsgTimeout time.Duration) error {
msg, err := c.popInFlightMessage(clientID, id)
if err != nil {
return err
}
c.removeFromInFlightPQ(msg)
newTimeout := time.Now().Add(clientMsgTimeout)
if newTimeout.Sub(msg.deliveryTS) >=
c.ctx.nsqd.getOpts()... | [
"func",
"(",
"c",
"*",
"Channel",
")",
"TouchMessage",
"(",
"clientID",
"int64",
",",
"id",
"MessageID",
",",
"clientMsgTimeout",
"time",
".",
"Duration",
")",
"error",
"{",
"msg",
",",
"err",
":=",
"c",
".",
"popInFlightMessage",
"(",
"clientID",
",",
"... | // TouchMessage resets the timeout for an in-flight message | [
"TouchMessage",
"resets",
"the",
"timeout",
"for",
"an",
"in",
"-",
"flight",
"message"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L325-L346 |
127,338 | nsqio/nsq | nsqd/channel.go | FinishMessage | func (c *Channel) FinishMessage(clientID int64, id MessageID) error {
msg, err := c.popInFlightMessage(clientID, id)
if err != nil {
return err
}
c.removeFromInFlightPQ(msg)
if c.e2eProcessingLatencyStream != nil {
c.e2eProcessingLatencyStream.Insert(msg.Timestamp)
}
return nil
} | go | func (c *Channel) FinishMessage(clientID int64, id MessageID) error {
msg, err := c.popInFlightMessage(clientID, id)
if err != nil {
return err
}
c.removeFromInFlightPQ(msg)
if c.e2eProcessingLatencyStream != nil {
c.e2eProcessingLatencyStream.Insert(msg.Timestamp)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Channel",
")",
"FinishMessage",
"(",
"clientID",
"int64",
",",
"id",
"MessageID",
")",
"error",
"{",
"msg",
",",
"err",
":=",
"c",
".",
"popInFlightMessage",
"(",
"clientID",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // FinishMessage successfully discards an in-flight message | [
"FinishMessage",
"successfully",
"discards",
"an",
"in",
"-",
"flight",
"message"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L349-L359 |
127,339 | nsqio/nsq | nsqd/channel.go | AddClient | func (c *Channel) AddClient(clientID int64, client Consumer) error {
c.Lock()
defer c.Unlock()
_, ok := c.clients[clientID]
if ok {
return nil
}
maxChannelConsumers := c.ctx.nsqd.getOpts().MaxChannelConsumers
if maxChannelConsumers != 0 && len(c.clients) >= maxChannelConsumers {
return errors.New("E_TOO_MA... | go | func (c *Channel) AddClient(clientID int64, client Consumer) error {
c.Lock()
defer c.Unlock()
_, ok := c.clients[clientID]
if ok {
return nil
}
maxChannelConsumers := c.ctx.nsqd.getOpts().MaxChannelConsumers
if maxChannelConsumers != 0 && len(c.clients) >= maxChannelConsumers {
return errors.New("E_TOO_MA... | [
"func",
"(",
"c",
"*",
"Channel",
")",
"AddClient",
"(",
"clientID",
"int64",
",",
"client",
"Consumer",
")",
"error",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"_",
",",
"ok",
":=",
"c",
".",
"clients"... | // AddClient adds a client to the Channel's client list | [
"AddClient",
"adds",
"a",
"client",
"to",
"the",
"Channel",
"s",
"client",
"list"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L392-L408 |
127,340 | nsqio/nsq | nsqd/channel.go | RemoveClient | func (c *Channel) RemoveClient(clientID int64) {
c.Lock()
defer c.Unlock()
_, ok := c.clients[clientID]
if !ok {
return
}
delete(c.clients, clientID)
if len(c.clients) == 0 && c.ephemeral == true {
go c.deleter.Do(func() { c.deleteCallback(c) })
}
} | go | func (c *Channel) RemoveClient(clientID int64) {
c.Lock()
defer c.Unlock()
_, ok := c.clients[clientID]
if !ok {
return
}
delete(c.clients, clientID)
if len(c.clients) == 0 && c.ephemeral == true {
go c.deleter.Do(func() { c.deleteCallback(c) })
}
} | [
"func",
"(",
"c",
"*",
"Channel",
")",
"RemoveClient",
"(",
"clientID",
"int64",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"_",
",",
"ok",
":=",
"c",
".",
"clients",
"[",
"clientID",
"]",
"\n",
"... | // RemoveClient removes a client from the Channel's client list | [
"RemoveClient",
"removes",
"a",
"client",
"from",
"the",
"Channel",
"s",
"client",
"list"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L411-L424 |
127,341 | nsqio/nsq | nsqd/channel.go | pushInFlightMessage | func (c *Channel) pushInFlightMessage(msg *Message) error {
c.inFlightMutex.Lock()
_, ok := c.inFlightMessages[msg.ID]
if ok {
c.inFlightMutex.Unlock()
return errors.New("ID already in flight")
}
c.inFlightMessages[msg.ID] = msg
c.inFlightMutex.Unlock()
return nil
} | go | func (c *Channel) pushInFlightMessage(msg *Message) error {
c.inFlightMutex.Lock()
_, ok := c.inFlightMessages[msg.ID]
if ok {
c.inFlightMutex.Unlock()
return errors.New("ID already in flight")
}
c.inFlightMessages[msg.ID] = msg
c.inFlightMutex.Unlock()
return nil
} | [
"func",
"(",
"c",
"*",
"Channel",
")",
"pushInFlightMessage",
"(",
"msg",
"*",
"Message",
")",
"error",
"{",
"c",
".",
"inFlightMutex",
".",
"Lock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"c",
".",
"inFlightMessages",
"[",
"msg",
".",
"ID",
"]",
"\n... | // pushInFlightMessage atomically adds a message to the in-flight dictionary | [
"pushInFlightMessage",
"atomically",
"adds",
"a",
"message",
"to",
"the",
"in",
"-",
"flight",
"dictionary"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L451-L461 |
127,342 | nsqio/nsq | nsqd/channel.go | popInFlightMessage | func (c *Channel) popInFlightMessage(clientID int64, id MessageID) (*Message, error) {
c.inFlightMutex.Lock()
msg, ok := c.inFlightMessages[id]
if !ok {
c.inFlightMutex.Unlock()
return nil, errors.New("ID not in flight")
}
if msg.clientID != clientID {
c.inFlightMutex.Unlock()
return nil, errors.New("clien... | go | func (c *Channel) popInFlightMessage(clientID int64, id MessageID) (*Message, error) {
c.inFlightMutex.Lock()
msg, ok := c.inFlightMessages[id]
if !ok {
c.inFlightMutex.Unlock()
return nil, errors.New("ID not in flight")
}
if msg.clientID != clientID {
c.inFlightMutex.Unlock()
return nil, errors.New("clien... | [
"func",
"(",
"c",
"*",
"Channel",
")",
"popInFlightMessage",
"(",
"clientID",
"int64",
",",
"id",
"MessageID",
")",
"(",
"*",
"Message",
",",
"error",
")",
"{",
"c",
".",
"inFlightMutex",
".",
"Lock",
"(",
")",
"\n",
"msg",
",",
"ok",
":=",
"c",
".... | // popInFlightMessage atomically removes a message from the in-flight dictionary | [
"popInFlightMessage",
"atomically",
"removes",
"a",
"message",
"from",
"the",
"in",
"-",
"flight",
"dictionary"
] | 223e97fc0e0f384710fb8d30cc52d4419e000810 | https://github.com/nsqio/nsq/blob/223e97fc0e0f384710fb8d30cc52d4419e000810/nsqd/channel.go#L464-L478 |
127,343 | ipfs/go-ipfs | core/coreunix/add.go | NewAdder | func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCLocker, ds ipld.DAGService) (*Adder, error) {
bufferedDS := ipld.NewBufferedDAG(ctx, ds)
return &Adder{
ctx: ctx,
pinning: p,
gcLocker: bs,
dagService: ds,
bufferedDS: bufferedDS,
Progress: false,
Pin: true,
Trickle: ... | go | func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCLocker, ds ipld.DAGService) (*Adder, error) {
bufferedDS := ipld.NewBufferedDAG(ctx, ds)
return &Adder{
ctx: ctx,
pinning: p,
gcLocker: bs,
dagService: ds,
bufferedDS: bufferedDS,
Progress: false,
Pin: true,
Trickle: ... | [
"func",
"NewAdder",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"pin",
".",
"Pinner",
",",
"bs",
"bstore",
".",
"GCLocker",
",",
"ds",
"ipld",
".",
"DAGService",
")",
"(",
"*",
"Adder",
",",
"error",
")",
"{",
"bufferedDS",
":=",
"ipld",
".",
... | // NewAdder Returns a new Adder used for a file add operation. | [
"NewAdder",
"Returns",
"a",
"new",
"Adder",
"used",
"for",
"a",
"file",
"add",
"operation",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreunix/add.go#L43-L57 |
127,344 | ipfs/go-ipfs | core/coreunix/add.go | add | func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
chnk, err := chunker.FromString(reader, adder.Chunker)
if err != nil {
return nil, err
}
params := ihelper.DagBuilderParams{
Dagserv: adder.bufferedDS,
RawLeaves: adder.RawLeaves,
Maxlinks: ihelper.DefaultLinksPerBlock,
NoCopy: adde... | go | func (adder *Adder) add(reader io.Reader) (ipld.Node, error) {
chnk, err := chunker.FromString(reader, adder.Chunker)
if err != nil {
return nil, err
}
params := ihelper.DagBuilderParams{
Dagserv: adder.bufferedDS,
RawLeaves: adder.RawLeaves,
Maxlinks: ihelper.DefaultLinksPerBlock,
NoCopy: adde... | [
"func",
"(",
"adder",
"*",
"Adder",
")",
"add",
"(",
"reader",
"io",
".",
"Reader",
")",
"(",
"ipld",
".",
"Node",
",",
"error",
")",
"{",
"chnk",
",",
"err",
":=",
"chunker",
".",
"FromString",
"(",
"reader",
",",
"adder",
".",
"Chunker",
")",
"... | // Constructs a node from reader's data, and adds it. Doesn't pin. | [
"Constructs",
"a",
"node",
"from",
"reader",
"s",
"data",
"and",
"adds",
"it",
".",
"Doesn",
"t",
"pin",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreunix/add.go#L101-L130 |
127,345 | ipfs/go-ipfs | core/coreunix/add.go | curRootNode | func (adder *Adder) curRootNode() (ipld.Node, error) {
mr, err := adder.mfsRoot()
if err != nil {
return nil, err
}
root, err := mr.GetDirectory().GetNode()
if err != nil {
return nil, err
}
// if one root file, use that hash as root.
if len(root.Links()) == 1 {
nd, err := root.Links()[0].GetNode(adder.c... | go | func (adder *Adder) curRootNode() (ipld.Node, error) {
mr, err := adder.mfsRoot()
if err != nil {
return nil, err
}
root, err := mr.GetDirectory().GetNode()
if err != nil {
return nil, err
}
// if one root file, use that hash as root.
if len(root.Links()) == 1 {
nd, err := root.Links()[0].GetNode(adder.c... | [
"func",
"(",
"adder",
"*",
"Adder",
")",
"curRootNode",
"(",
")",
"(",
"ipld",
".",
"Node",
",",
"error",
")",
"{",
"mr",
",",
"err",
":=",
"adder",
".",
"mfsRoot",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n... | // RootNode returns the mfs root node | [
"RootNode",
"returns",
"the",
"mfs",
"root",
"node"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreunix/add.go#L133-L154 |
127,346 | ipfs/go-ipfs | core/coreunix/add.go | PinRoot | func (adder *Adder) PinRoot(root ipld.Node) error {
if !adder.Pin {
return nil
}
rnk := root.Cid()
err := adder.dagService.Add(adder.ctx, root)
if err != nil {
return err
}
if adder.tempRoot.Defined() {
err := adder.pinning.Unpin(adder.ctx, adder.tempRoot, true)
if err != nil {
return err
}
add... | go | func (adder *Adder) PinRoot(root ipld.Node) error {
if !adder.Pin {
return nil
}
rnk := root.Cid()
err := adder.dagService.Add(adder.ctx, root)
if err != nil {
return err
}
if adder.tempRoot.Defined() {
err := adder.pinning.Unpin(adder.ctx, adder.tempRoot, true)
if err != nil {
return err
}
add... | [
"func",
"(",
"adder",
"*",
"Adder",
")",
"PinRoot",
"(",
"root",
"ipld",
".",
"Node",
")",
"error",
"{",
"if",
"!",
"adder",
".",
"Pin",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"rnk",
":=",
"root",
".",
"Cid",
"(",
")",
"\n\n",
"err",
":=",
"a... | // Recursively pins the root node of Adder and
// writes the pin state to the backing datastore. | [
"Recursively",
"pins",
"the",
"root",
"node",
"of",
"Adder",
"and",
"writes",
"the",
"pin",
"state",
"to",
"the",
"backing",
"datastore",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreunix/add.go#L158-L180 |
127,347 | ipfs/go-ipfs | core/coreunix/add.go | outputDagnode | func outputDagnode(out chan<- interface{}, name string, dn ipld.Node) error {
if out == nil {
return nil
}
o, err := getOutput(dn)
if err != nil {
return err
}
out <- &coreiface.AddEvent{
Path: o.Path,
Name: name,
Size: o.Size,
}
return nil
} | go | func outputDagnode(out chan<- interface{}, name string, dn ipld.Node) error {
if out == nil {
return nil
}
o, err := getOutput(dn)
if err != nil {
return err
}
out <- &coreiface.AddEvent{
Path: o.Path,
Name: name,
Size: o.Size,
}
return nil
} | [
"func",
"outputDagnode",
"(",
"out",
"chan",
"<-",
"interface",
"{",
"}",
",",
"name",
"string",
",",
"dn",
"ipld",
".",
"Node",
")",
"error",
"{",
"if",
"out",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"o",
",",
"err",
":=",
"getOutput... | // outputDagnode sends dagnode info over the output channel | [
"outputDagnode",
"sends",
"dagnode",
"info",
"over",
"the",
"output",
"channel"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreunix/add.go#L447-L464 |
127,348 | ipfs/go-ipfs | core/commands/p2p.go | checkPort | func checkPort(target ma.Multiaddr) error {
// get tcp or udp port from multiaddr
getPort := func() (string, error) {
sport, _ := target.ValueForProtocol(ma.P_TCP)
if sport != "" {
return sport, nil
}
sport, _ = target.ValueForProtocol(ma.P_UDP)
if sport != "" {
return sport, nil
}
return "", fmt... | go | func checkPort(target ma.Multiaddr) error {
// get tcp or udp port from multiaddr
getPort := func() (string, error) {
sport, _ := target.ValueForProtocol(ma.P_TCP)
if sport != "" {
return sport, nil
}
sport, _ = target.ValueForProtocol(ma.P_UDP)
if sport != "" {
return sport, nil
}
return "", fmt... | [
"func",
"checkPort",
"(",
"target",
"ma",
".",
"Multiaddr",
")",
"error",
"{",
"// get tcp or udp port from multiaddr",
"getPort",
":=",
"func",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"sport",
",",
"_",
":=",
"target",
".",
"ValueForProtocol",
"(",... | // checkPort checks whether target multiaddr contains tcp or udp protocol
// and whether the port is equal to 0 | [
"checkPort",
"checks",
"whether",
"target",
"multiaddr",
"contains",
"tcp",
"or",
"udp",
"protocol",
"and",
"whether",
"the",
"port",
"is",
"equal",
"to",
"0"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/p2p.go#L227-L257 |
127,349 | ipfs/go-ipfs | core/commands/p2p.go | forwardLocal | func forwardLocal(ctx context.Context, p *p2p.P2P, ps pstore.Peerstore, proto protocol.ID, bindAddr ma.Multiaddr, addrs []ipfsaddr.IPFSAddr) error {
for _, addr := range addrs {
ps.AddAddr(addr.ID(), addr.Multiaddr(), pstore.TempAddrTTL)
}
// TODO: return some info
// the length of the addrs must large than 0
//... | go | func forwardLocal(ctx context.Context, p *p2p.P2P, ps pstore.Peerstore, proto protocol.ID, bindAddr ma.Multiaddr, addrs []ipfsaddr.IPFSAddr) error {
for _, addr := range addrs {
ps.AddAddr(addr.ID(), addr.Multiaddr(), pstore.TempAddrTTL)
}
// TODO: return some info
// the length of the addrs must large than 0
//... | [
"func",
"forwardLocal",
"(",
"ctx",
"context",
".",
"Context",
",",
"p",
"*",
"p2p",
".",
"P2P",
",",
"ps",
"pstore",
".",
"Peerstore",
",",
"proto",
"protocol",
".",
"ID",
",",
"bindAddr",
"ma",
".",
"Multiaddr",
",",
"addrs",
"[",
"]",
"ipfsaddr",
... | // forwardLocal forwards local connections to a libp2p service | [
"forwardLocal",
"forwards",
"local",
"connections",
"to",
"a",
"libp2p",
"service"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/p2p.go#L260-L269 |
127,350 | ipfs/go-ipfs | assets/assets.go | SeedInitDocs | func SeedInitDocs(nd *core.IpfsNode) (cid.Cid, error) {
return addAssetList(nd, initDocPaths)
} | go | func SeedInitDocs(nd *core.IpfsNode) (cid.Cid, error) {
return addAssetList(nd, initDocPaths)
} | [
"func",
"SeedInitDocs",
"(",
"nd",
"*",
"core",
".",
"IpfsNode",
")",
"(",
"cid",
".",
"Cid",
",",
"error",
")",
"{",
"return",
"addAssetList",
"(",
"nd",
",",
"initDocPaths",
")",
"\n",
"}"
] | // SeedInitDocs adds the list of embedded init documentation to the passed node, pins it and returns the root key | [
"SeedInitDocs",
"adds",
"the",
"list",
"of",
"embedded",
"init",
"documentation",
"to",
"the",
"passed",
"node",
"pins",
"it",
"and",
"returns",
"the",
"root",
"key"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/assets/assets.go#L35-L37 |
127,351 | ipfs/go-ipfs | fuse/readonly/mount_unix.go | Mount | func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
cfg, err := ipfs.Repo.Config()
if err != nil {
return nil, err
}
allow_other := cfg.Mounts.FuseAllowOther
fsys := NewFileSystem(ipfs)
return mount.NewMount(ipfs.Process, fsys, mountpoint, allow_other)
} | go | func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
cfg, err := ipfs.Repo.Config()
if err != nil {
return nil, err
}
allow_other := cfg.Mounts.FuseAllowOther
fsys := NewFileSystem(ipfs)
return mount.NewMount(ipfs.Process, fsys, mountpoint, allow_other)
} | [
"func",
"Mount",
"(",
"ipfs",
"*",
"core",
".",
"IpfsNode",
",",
"mountpoint",
"string",
")",
"(",
"mount",
".",
"Mount",
",",
"error",
")",
"{",
"cfg",
",",
"err",
":=",
"ipfs",
".",
"Repo",
".",
"Config",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil... | // Mount mounts IPFS at a given location, and returns a mount.Mount instance. | [
"Mount",
"mounts",
"IPFS",
"at",
"a",
"given",
"location",
"and",
"returns",
"a",
"mount",
".",
"Mount",
"instance",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/readonly/mount_unix.go#L12-L20 |
127,352 | ipfs/go-ipfs | fuse/readonly/readonly_unix.go | ReadDirAll | func (*Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
log.Debug("read Root")
return nil, fuse.EPERM
} | go | func (*Root) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
log.Debug("read Root")
return nil, fuse.EPERM
} | [
"func",
"(",
"*",
"Root",
")",
"ReadDirAll",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"fuse",
".",
"Dirent",
",",
"error",
")",
"{",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",",
"fuse",
".",
"EPERM",
... | // ReadDirAll reads a particular directory. Disallowed for root. | [
"ReadDirAll",
"reads",
"a",
"particular",
"directory",
".",
"Disallowed",
"for",
"root",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/readonly/readonly_unix.go#L86-L89 |
127,353 | ipfs/go-ipfs | pin/pin.go | ModeToString | func ModeToString(mode Mode) (string, bool) {
m := map[Mode]string{
Recursive: linkRecursive,
Direct: linkDirect,
Indirect: linkIndirect,
Internal: linkInternal,
NotPinned: linkNotPinned,
Any: linkAny,
}
s, ok := m[mode]
return s, ok
} | go | func ModeToString(mode Mode) (string, bool) {
m := map[Mode]string{
Recursive: linkRecursive,
Direct: linkDirect,
Indirect: linkIndirect,
Internal: linkInternal,
NotPinned: linkNotPinned,
Any: linkAny,
}
s, ok := m[mode]
return s, ok
} | [
"func",
"ModeToString",
"(",
"mode",
"Mode",
")",
"(",
"string",
",",
"bool",
")",
"{",
"m",
":=",
"map",
"[",
"Mode",
"]",
"string",
"{",
"Recursive",
":",
"linkRecursive",
",",
"Direct",
":",
"linkDirect",
",",
"Indirect",
":",
"linkIndirect",
",",
"... | // ModeToString returns a human-readable name for the Mode. | [
"ModeToString",
"returns",
"a",
"human",
"-",
"readable",
"name",
"for",
"the",
"Mode",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L72-L83 |
127,354 | ipfs/go-ipfs | pin/pin.go | String | func (p Pinned) String() string {
switch p.Mode {
case NotPinned:
return "not pinned"
case Indirect:
return fmt.Sprintf("pinned via %s", p.Via)
default:
modeStr, _ := ModeToString(p.Mode)
return fmt.Sprintf("pinned: %s", modeStr)
}
} | go | func (p Pinned) String() string {
switch p.Mode {
case NotPinned:
return "not pinned"
case Indirect:
return fmt.Sprintf("pinned via %s", p.Via)
default:
modeStr, _ := ModeToString(p.Mode)
return fmt.Sprintf("pinned: %s", modeStr)
}
} | [
"func",
"(",
"p",
"Pinned",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"p",
".",
"Mode",
"{",
"case",
"NotPinned",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Indirect",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"p",
".",
"... | // String Returns pin status as string | [
"String",
"Returns",
"pin",
"status",
"as",
"string"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L170-L180 |
127,355 | ipfs/go-ipfs | pin/pin.go | NewPinner | func NewPinner(dstore ds.Datastore, serv, internal ipld.DAGService) Pinner {
rcset := cid.NewSet()
dirset := cid.NewSet()
return &pinner{
recursePin: rcset,
directPin: dirset,
dserv: serv,
dstore: dstore,
internal: internal,
internalPin: cid.NewSet(),
}
} | go | func NewPinner(dstore ds.Datastore, serv, internal ipld.DAGService) Pinner {
rcset := cid.NewSet()
dirset := cid.NewSet()
return &pinner{
recursePin: rcset,
directPin: dirset,
dserv: serv,
dstore: dstore,
internal: internal,
internalPin: cid.NewSet(),
}
} | [
"func",
"NewPinner",
"(",
"dstore",
"ds",
".",
"Datastore",
",",
"serv",
",",
"internal",
"ipld",
".",
"DAGService",
")",
"Pinner",
"{",
"rcset",
":=",
"cid",
".",
"NewSet",
"(",
")",
"\n",
"dirset",
":=",
"cid",
".",
"NewSet",
"(",
")",
"\n\n",
"ret... | // NewPinner creates a new pinner using the given datastore as a backend | [
"NewPinner",
"creates",
"a",
"new",
"pinner",
"using",
"the",
"given",
"datastore",
"as",
"a",
"backend"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L197-L210 |
127,356 | ipfs/go-ipfs | pin/pin.go | Pin | func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error {
p.lock.Lock()
defer p.lock.Unlock()
err := p.dserv.Add(ctx, node)
if err != nil {
return err
}
c := node.Cid()
if recurse {
if p.recursePin.Has(c) {
return nil
}
if p.directPin.Has(c) {
p.directPin.Remove(c)
}
p.... | go | func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error {
p.lock.Lock()
defer p.lock.Unlock()
err := p.dserv.Add(ctx, node)
if err != nil {
return err
}
c := node.Cid()
if recurse {
if p.recursePin.Has(c) {
return nil
}
if p.directPin.Has(c) {
p.directPin.Remove(c)
}
p.... | [
"func",
"(",
"p",
"*",
"pinner",
")",
"Pin",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"ipld",
".",
"Node",
",",
"recurse",
"bool",
")",
"error",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unl... | // Pin the given node, optionally recursive | [
"Pin",
"the",
"given",
"node",
"optionally",
"recursive"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L213-L263 |
127,357 | ipfs/go-ipfs | pin/pin.go | Unpin | func (p *pinner) Unpin(ctx context.Context, c cid.Cid, recursive bool) error {
p.lock.Lock()
defer p.lock.Unlock()
reason, pinned, err := p.isPinnedWithType(c, Any)
if err != nil {
return err
}
if !pinned {
return ErrNotPinned
}
switch reason {
case "recursive":
if recursive {
p.recursePin.Remove(c)
... | go | func (p *pinner) Unpin(ctx context.Context, c cid.Cid, recursive bool) error {
p.lock.Lock()
defer p.lock.Unlock()
reason, pinned, err := p.isPinnedWithType(c, Any)
if err != nil {
return err
}
if !pinned {
return ErrNotPinned
}
switch reason {
case "recursive":
if recursive {
p.recursePin.Remove(c)
... | [
"func",
"(",
"p",
"*",
"pinner",
")",
"Unpin",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"cid",
".",
"Cid",
",",
"recursive",
"bool",
")",
"error",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlo... | // Unpin a given key | [
"Unpin",
"a",
"given",
"key"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L269-L292 |
127,358 | ipfs/go-ipfs | pin/pin.go | IsPinned | func (p *pinner) IsPinned(c cid.Cid) (string, bool, error) {
p.lock.RLock()
defer p.lock.RUnlock()
return p.isPinnedWithType(c, Any)
} | go | func (p *pinner) IsPinned(c cid.Cid) (string, bool, error) {
p.lock.RLock()
defer p.lock.RUnlock()
return p.isPinnedWithType(c, Any)
} | [
"func",
"(",
"p",
"*",
"pinner",
")",
"IsPinned",
"(",
"c",
"cid",
".",
"Cid",
")",
"(",
"string",
",",
"bool",
",",
"error",
")",
"{",
"p",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",... | // IsPinned returns whether or not the given key is pinned
// and an explanation of why its pinned | [
"IsPinned",
"returns",
"whether",
"or",
"not",
"the",
"given",
"key",
"is",
"pinned",
"and",
"an",
"explanation",
"of",
"why",
"its",
"pinned"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L300-L304 |
127,359 | ipfs/go-ipfs | pin/pin.go | IsPinnedWithType | func (p *pinner) IsPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) {
p.lock.RLock()
defer p.lock.RUnlock()
return p.isPinnedWithType(c, mode)
} | go | func (p *pinner) IsPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) {
p.lock.RLock()
defer p.lock.RUnlock()
return p.isPinnedWithType(c, mode)
} | [
"func",
"(",
"p",
"*",
"pinner",
")",
"IsPinnedWithType",
"(",
"c",
"cid",
".",
"Cid",
",",
"mode",
"Mode",
")",
"(",
"string",
",",
"bool",
",",
"error",
")",
"{",
"p",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",... | // IsPinnedWithType returns whether or not the given cid is pinned with the
// given pin type, as well as returning the type of pin its pinned with. | [
"IsPinnedWithType",
"returns",
"whether",
"or",
"not",
"the",
"given",
"cid",
"is",
"pinned",
"with",
"the",
"given",
"pin",
"type",
"as",
"well",
"as",
"returning",
"the",
"type",
"of",
"pin",
"its",
"pinned",
"with",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L308-L312 |
127,360 | ipfs/go-ipfs | pin/pin.go | isPinnedWithType | func (p *pinner) isPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) {
switch mode {
case Any, Direct, Indirect, Recursive, Internal:
default:
err := fmt.Errorf("invalid Pin Mode '%d', must be one of {%d, %d, %d, %d, %d}",
mode, Direct, Indirect, Recursive, Internal, Any)
return "", false, err
}
if... | go | func (p *pinner) isPinnedWithType(c cid.Cid, mode Mode) (string, bool, error) {
switch mode {
case Any, Direct, Indirect, Recursive, Internal:
default:
err := fmt.Errorf("invalid Pin Mode '%d', must be one of {%d, %d, %d, %d, %d}",
mode, Direct, Indirect, Recursive, Internal, Any)
return "", false, err
}
if... | [
"func",
"(",
"p",
"*",
"pinner",
")",
"isPinnedWithType",
"(",
"c",
"cid",
".",
"Cid",
",",
"mode",
"Mode",
")",
"(",
"string",
",",
"bool",
",",
"error",
")",
"{",
"switch",
"mode",
"{",
"case",
"Any",
",",
"Direct",
",",
"Indirect",
",",
"Recursi... | // isPinnedWithType is the implementation of IsPinnedWithType that does not lock.
// intended for use by other pinned methods that already take locks | [
"isPinnedWithType",
"is",
"the",
"implementation",
"of",
"IsPinnedWithType",
"that",
"does",
"not",
"lock",
".",
"intended",
"for",
"use",
"by",
"other",
"pinned",
"methods",
"that",
"already",
"take",
"locks"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L316-L357 |
127,361 | ipfs/go-ipfs | pin/pin.go | RemovePinWithMode | func (p *pinner) RemovePinWithMode(c cid.Cid, mode Mode) {
p.lock.Lock()
defer p.lock.Unlock()
switch mode {
case Direct:
p.directPin.Remove(c)
case Recursive:
p.recursePin.Remove(c)
default:
// programmer error, panic OK
panic("unrecognized pin type")
}
} | go | func (p *pinner) RemovePinWithMode(c cid.Cid, mode Mode) {
p.lock.Lock()
defer p.lock.Unlock()
switch mode {
case Direct:
p.directPin.Remove(c)
case Recursive:
p.recursePin.Remove(c)
default:
// programmer error, panic OK
panic("unrecognized pin type")
}
} | [
"func",
"(",
"p",
"*",
"pinner",
")",
"RemovePinWithMode",
"(",
"c",
"cid",
".",
"Cid",
",",
"mode",
"Mode",
")",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"switch",
"mode",
"{... | // RemovePinWithMode is for manually editing the pin structure.
// Use with care! If used improperly, garbage collection may not
// be successful. | [
"RemovePinWithMode",
"is",
"for",
"manually",
"editing",
"the",
"pin",
"structure",
".",
"Use",
"with",
"care!",
"If",
"used",
"improperly",
"garbage",
"collection",
"may",
"not",
"be",
"successful",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L429-L441 |
127,362 | ipfs/go-ipfs | pin/pin.go | LoadPinner | func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error) {
p := new(pinner)
rootKey, err := d.Get(pinDatastoreKey)
if err != nil {
return nil, fmt.Errorf("cannot load pin state: %v", err)
}
rootCid, err := cid.Cast(rootKey)
if err != nil {
return nil, err
}
ctx, cancel := context.W... | go | func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error) {
p := new(pinner)
rootKey, err := d.Get(pinDatastoreKey)
if err != nil {
return nil, fmt.Errorf("cannot load pin state: %v", err)
}
rootCid, err := cid.Cast(rootKey)
if err != nil {
return nil, err
}
ctx, cancel := context.W... | [
"func",
"LoadPinner",
"(",
"d",
"ds",
".",
"Datastore",
",",
"dserv",
",",
"internal",
"ipld",
".",
"DAGService",
")",
"(",
"Pinner",
",",
"error",
")",
"{",
"p",
":=",
"new",
"(",
"pinner",
")",
"\n\n",
"rootKey",
",",
"err",
":=",
"d",
".",
"Get"... | // LoadPinner loads a pinner and its keysets from the given datastore | [
"LoadPinner",
"loads",
"a",
"pinner",
"and",
"its",
"keysets",
"from",
"the",
"given",
"datastore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L452-L505 |
127,363 | ipfs/go-ipfs | pin/pin.go | Update | func (p *pinner) Update(ctx context.Context, from, to cid.Cid, unpin bool) error {
p.lock.Lock()
defer p.lock.Unlock()
if !p.recursePin.Has(from) {
return fmt.Errorf("'from' cid was not recursively pinned already")
}
err := dagutils.DiffEnumerate(ctx, p.dserv, from, to)
if err != nil {
return err
}
p.rec... | go | func (p *pinner) Update(ctx context.Context, from, to cid.Cid, unpin bool) error {
p.lock.Lock()
defer p.lock.Unlock()
if !p.recursePin.Has(from) {
return fmt.Errorf("'from' cid was not recursively pinned already")
}
err := dagutils.DiffEnumerate(ctx, p.dserv, from, to)
if err != nil {
return err
}
p.rec... | [
"func",
"(",
"p",
"*",
"pinner",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"from",
",",
"to",
"cid",
".",
"Cid",
",",
"unpin",
"bool",
")",
"error",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",... | // Update updates a recursive pin from one cid to another
// this is more efficient than simply pinning the new one and unpinning the
// old one | [
"Update",
"updates",
"a",
"recursive",
"pin",
"from",
"one",
"cid",
"to",
"another",
"this",
"is",
"more",
"efficient",
"than",
"simply",
"pinning",
"the",
"new",
"one",
"and",
"unpinning",
"the",
"old",
"one"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L520-L538 |
127,364 | ipfs/go-ipfs | pin/pin.go | Flush | func (p *pinner) Flush() error {
p.lock.Lock()
defer p.lock.Unlock()
ctx := context.TODO()
internalset := cid.NewSet()
recordInternal := internalset.Add
root := &mdag.ProtoNode{}
{
n, err := storeSet(ctx, p.internal, p.directPin.Keys(), recordInternal)
if err != nil {
return err
}
if err := root.Ad... | go | func (p *pinner) Flush() error {
p.lock.Lock()
defer p.lock.Unlock()
ctx := context.TODO()
internalset := cid.NewSet()
recordInternal := internalset.Add
root := &mdag.ProtoNode{}
{
n, err := storeSet(ctx, p.internal, p.directPin.Keys(), recordInternal)
if err != nil {
return err
}
if err := root.Ad... | [
"func",
"(",
"p",
"*",
"pinner",
")",
"Flush",
"(",
")",
"error",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n\n",
"internalse... | // Flush encodes and writes pinner keysets to the datastore | [
"Flush",
"encodes",
"and",
"writes",
"pinner",
"keysets",
"to",
"the",
"datastore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L541-L590 |
127,365 | ipfs/go-ipfs | pin/pin.go | InternalPins | func (p *pinner) InternalPins() []cid.Cid {
p.lock.Lock()
defer p.lock.Unlock()
var out []cid.Cid
out = append(out, p.internalPin.Keys()...)
return out
} | go | func (p *pinner) InternalPins() []cid.Cid {
p.lock.Lock()
defer p.lock.Unlock()
var out []cid.Cid
out = append(out, p.internalPin.Keys()...)
return out
} | [
"func",
"(",
"p",
"*",
"pinner",
")",
"InternalPins",
"(",
")",
"[",
"]",
"cid",
".",
"Cid",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"var",
"out",
"[",
"]",
"cid",
".",
"... | // InternalPins returns all cids kept pinned for the internal state of the
// pinner | [
"InternalPins",
"returns",
"all",
"cids",
"kept",
"pinned",
"for",
"the",
"internal",
"state",
"of",
"the",
"pinner"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L594-L600 |
127,366 | ipfs/go-ipfs | pin/pin.go | PinWithMode | func (p *pinner) PinWithMode(c cid.Cid, mode Mode) {
p.lock.Lock()
defer p.lock.Unlock()
switch mode {
case Recursive:
p.recursePin.Add(c)
case Direct:
p.directPin.Add(c)
}
} | go | func (p *pinner) PinWithMode(c cid.Cid, mode Mode) {
p.lock.Lock()
defer p.lock.Unlock()
switch mode {
case Recursive:
p.recursePin.Add(c)
case Direct:
p.directPin.Add(c)
}
} | [
"func",
"(",
"p",
"*",
"pinner",
")",
"PinWithMode",
"(",
"c",
"cid",
".",
"Cid",
",",
"mode",
"Mode",
")",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"switch",
"mode",
"{",
"... | // PinWithMode allows the user to have fine grained control over pin
// counts | [
"PinWithMode",
"allows",
"the",
"user",
"to",
"have",
"fine",
"grained",
"control",
"over",
"pin",
"counts"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L604-L613 |
127,367 | ipfs/go-ipfs | pin/pin.go | hasChild | func hasChild(ng ipld.NodeGetter, root cid.Cid, child cid.Cid, visit func(cid.Cid) bool) (bool, error) {
links, err := ipld.GetLinks(context.TODO(), ng, root)
if err != nil {
return false, err
}
for _, lnk := range links {
c := lnk.Cid
if lnk.Cid.Equals(child) {
return true, nil
}
if visit(c) {
has,... | go | func hasChild(ng ipld.NodeGetter, root cid.Cid, child cid.Cid, visit func(cid.Cid) bool) (bool, error) {
links, err := ipld.GetLinks(context.TODO(), ng, root)
if err != nil {
return false, err
}
for _, lnk := range links {
c := lnk.Cid
if lnk.Cid.Equals(child) {
return true, nil
}
if visit(c) {
has,... | [
"func",
"hasChild",
"(",
"ng",
"ipld",
".",
"NodeGetter",
",",
"root",
"cid",
".",
"Cid",
",",
"child",
"cid",
".",
"Cid",
",",
"visit",
"func",
"(",
"cid",
".",
"Cid",
")",
"bool",
")",
"(",
"bool",
",",
"error",
")",
"{",
"links",
",",
"err",
... | // hasChild recursively looks for a Cid among the children of a root Cid.
// The visit function can be used to shortcut already-visited branches. | [
"hasChild",
"recursively",
"looks",
"for",
"a",
"Cid",
"among",
"the",
"children",
"of",
"a",
"root",
"Cid",
".",
"The",
"visit",
"function",
"can",
"be",
"used",
"to",
"shortcut",
"already",
"-",
"visited",
"branches",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/pin/pin.go#L617-L639 |
127,368 | ipfs/go-ipfs | core/coredag/dagtransl.go | ParseInputs | func ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
return DefaultInputEncParsers.ParseInputs(ienc, format, r, mhType, mhLen)
} | go | func ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
return DefaultInputEncParsers.ParseInputs(ienc, format, r, mhType, mhLen)
} | [
"func",
"ParseInputs",
"(",
"ienc",
",",
"format",
"string",
",",
"r",
"io",
".",
"Reader",
",",
"mhType",
"uint64",
",",
"mhLen",
"int",
")",
"(",
"[",
"]",
"ipld",
".",
"Node",
",",
"error",
")",
"{",
"return",
"DefaultInputEncParsers",
".",
"ParseIn... | // ParseInputs uses DefaultInputEncParsers to parse io.Reader described by
// input encoding and format to an instance of ipld Node | [
"ParseInputs",
"uses",
"DefaultInputEncParsers",
"to",
"parse",
"io",
".",
"Reader",
"described",
"by",
"input",
"encoding",
"and",
"format",
"to",
"an",
"instance",
"of",
"ipld",
"Node"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coredag/dagtransl.go#L57-L59 |
127,369 | ipfs/go-ipfs | core/coredag/dagtransl.go | AddParser | func (iep InputEncParsers) AddParser(ienc, format string, f DagParser) {
m, ok := iep[ienc]
if !ok {
m = make(FormatParsers)
iep[ienc] = m
}
m[format] = f
} | go | func (iep InputEncParsers) AddParser(ienc, format string, f DagParser) {
m, ok := iep[ienc]
if !ok {
m = make(FormatParsers)
iep[ienc] = m
}
m[format] = f
} | [
"func",
"(",
"iep",
"InputEncParsers",
")",
"AddParser",
"(",
"ienc",
",",
"format",
"string",
",",
"f",
"DagParser",
")",
"{",
"m",
",",
"ok",
":=",
"iep",
"[",
"ienc",
"]",
"\n",
"if",
"!",
"ok",
"{",
"m",
"=",
"make",
"(",
"FormatParsers",
")",
... | // AddParser adds DagParser under give input encoding and format | [
"AddParser",
"adds",
"DagParser",
"under",
"give",
"input",
"encoding",
"and",
"format"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coredag/dagtransl.go#L62-L70 |
127,370 | ipfs/go-ipfs | core/coredag/dagtransl.go | ParseInputs | func (iep InputEncParsers) ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
parsers, ok := iep[ienc]
if !ok {
return nil, fmt.Errorf("no input parser for %q", ienc)
}
parser, ok := parsers[format]
if !ok {
return nil, fmt.Errorf("no parser for format %q using inpu... | go | func (iep InputEncParsers) ParseInputs(ienc, format string, r io.Reader, mhType uint64, mhLen int) ([]ipld.Node, error) {
parsers, ok := iep[ienc]
if !ok {
return nil, fmt.Errorf("no input parser for %q", ienc)
}
parser, ok := parsers[format]
if !ok {
return nil, fmt.Errorf("no parser for format %q using inpu... | [
"func",
"(",
"iep",
"InputEncParsers",
")",
"ParseInputs",
"(",
"ienc",
",",
"format",
"string",
",",
"r",
"io",
".",
"Reader",
",",
"mhType",
"uint64",
",",
"mhLen",
"int",
")",
"(",
"[",
"]",
"ipld",
".",
"Node",
",",
"error",
")",
"{",
"parsers",
... | // ParseInputs parses io.Reader described by input encoding and format to
// an instance of ipld Node | [
"ParseInputs",
"parses",
"io",
".",
"Reader",
"described",
"by",
"input",
"encoding",
"and",
"format",
"to",
"an",
"instance",
"of",
"ipld",
"Node"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coredag/dagtransl.go#L74-L86 |
127,371 | ipfs/go-ipfs | p2p/local.go | ForwardLocal | func (p2p *P2P) ForwardLocal(ctx context.Context, peer peer.ID, proto protocol.ID, bindAddr ma.Multiaddr) (Listener, error) {
listener := &localListener{
ctx: ctx,
p2p: p2p,
proto: proto,
peer: peer,
}
maListener, err := manet.Listen(bindAddr)
if err != nil {
return nil, err
}
listener.listener =... | go | func (p2p *P2P) ForwardLocal(ctx context.Context, peer peer.ID, proto protocol.ID, bindAddr ma.Multiaddr) (Listener, error) {
listener := &localListener{
ctx: ctx,
p2p: p2p,
proto: proto,
peer: peer,
}
maListener, err := manet.Listen(bindAddr)
if err != nil {
return nil, err
}
listener.listener =... | [
"func",
"(",
"p2p",
"*",
"P2P",
")",
"ForwardLocal",
"(",
"ctx",
"context",
".",
"Context",
",",
"peer",
"peer",
".",
"ID",
",",
"proto",
"protocol",
".",
"ID",
",",
"bindAddr",
"ma",
".",
"Multiaddr",
")",
"(",
"Listener",
",",
"error",
")",
"{",
... | // ForwardLocal creates new P2P stream to a remote listener | [
"ForwardLocal",
"creates",
"new",
"P2P",
"stream",
"to",
"a",
"remote",
"listener"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/p2p/local.go#L29-L52 |
127,372 | ipfs/go-ipfs | core/commands/cmdenv/cidbase.go | GetCidEncoder | func GetCidEncoder(req *cmds.Request) (cidenc.Encoder, error) {
return getCidBase(req, true)
} | go | func GetCidEncoder(req *cmds.Request) (cidenc.Encoder, error) {
return getCidBase(req, true)
} | [
"func",
"GetCidEncoder",
"(",
"req",
"*",
"cmds",
".",
"Request",
")",
"(",
"cidenc",
".",
"Encoder",
",",
"error",
")",
"{",
"return",
"getCidBase",
"(",
"req",
",",
"true",
")",
"\n",
"}"
] | // GetCidEncoder processes the `cid-base` and `output-cidv1` options and
// returns a encoder to use based on those parameters. | [
"GetCidEncoder",
"processes",
"the",
"cid",
"-",
"base",
"and",
"output",
"-",
"cidv1",
"options",
"and",
"returns",
"a",
"encoder",
"to",
"use",
"based",
"on",
"those",
"parameters",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/cidbase.go#L19-L21 |
127,373 | ipfs/go-ipfs | core/commands/cmdenv/cidbase.go | GetLowLevelCidEncoder | func GetLowLevelCidEncoder(req *cmds.Request) (cidenc.Encoder, error) {
return getCidBase(req, false)
} | go | func GetLowLevelCidEncoder(req *cmds.Request) (cidenc.Encoder, error) {
return getCidBase(req, false)
} | [
"func",
"GetLowLevelCidEncoder",
"(",
"req",
"*",
"cmds",
".",
"Request",
")",
"(",
"cidenc",
".",
"Encoder",
",",
"error",
")",
"{",
"return",
"getCidBase",
"(",
"req",
",",
"false",
")",
"\n",
"}"
] | // GetLowLevelCidEncoder is like GetCidEncoder but meant to be used by
// lower level commands. It differs from GetCidEncoder in that CIDv0
// are not, by default, auto-upgraded to CIDv1. | [
"GetLowLevelCidEncoder",
"is",
"like",
"GetCidEncoder",
"but",
"meant",
"to",
"be",
"used",
"by",
"lower",
"level",
"commands",
".",
"It",
"differs",
"from",
"GetCidEncoder",
"in",
"that",
"CIDv0",
"are",
"not",
"by",
"default",
"auto",
"-",
"upgraded",
"to",
... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/cidbase.go#L26-L28 |
127,374 | ipfs/go-ipfs | core/commands/cmdenv/cidbase.go | CidBaseDefined | func CidBaseDefined(req *cmds.Request) bool {
base, _ := req.Options["cid-base"].(string)
return base != ""
} | go | func CidBaseDefined(req *cmds.Request) bool {
base, _ := req.Options["cid-base"].(string)
return base != ""
} | [
"func",
"CidBaseDefined",
"(",
"req",
"*",
"cmds",
".",
"Request",
")",
"bool",
"{",
"base",
",",
"_",
":=",
"req",
".",
"Options",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"return",
"base",
"!=",
"\"",
"\"",
"\n",
"}"
] | // CidBaseDefined returns true if the `cid-base` option is specified
// on the command line | [
"CidBaseDefined",
"returns",
"true",
"if",
"the",
"cid",
"-",
"base",
"option",
"is",
"specified",
"on",
"the",
"command",
"line"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/commands/cmdenv/cidbase.go#L56-L59 |
127,375 | ipfs/go-ipfs | core/mock/mock.go | NewMockNode | func NewMockNode() (*core.IpfsNode, error) {
ctx := context.Background()
// effectively offline, only peer in its network
return core.NewNode(ctx, &core.BuildCfg{
Online: true,
Host: MockHostOption(mocknet.New(ctx)),
})
} | go | func NewMockNode() (*core.IpfsNode, error) {
ctx := context.Background()
// effectively offline, only peer in its network
return core.NewNode(ctx, &core.BuildCfg{
Online: true,
Host: MockHostOption(mocknet.New(ctx)),
})
} | [
"func",
"NewMockNode",
"(",
")",
"(",
"*",
"core",
".",
"IpfsNode",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n\n",
"// effectively offline, only peer in its network",
"return",
"core",
".",
"NewNode",
"(",
"ctx",
",",
"&... | // NewMockNode constructs an IpfsNode for use in tests. | [
"NewMockNode",
"constructs",
"an",
"IpfsNode",
"for",
"use",
"in",
"tests",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/mock/mock.go#L23-L31 |
127,376 | ipfs/go-ipfs | namesys/proquint.go | resolveOnceAsync | func (r *ProquintResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
out := make(chan onceResult, 1)
defer close(out)
ok, err := proquint.IsProquint(name)
if err != nil || !ok {
out <- onceResult{err: errors.New("not a valid proquint string")}
return out
... | go | func (r *ProquintResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
out := make(chan onceResult, 1)
defer close(out)
ok, err := proquint.IsProquint(name)
if err != nil || !ok {
out <- onceResult{err: errors.New("not a valid proquint string")}
return out
... | [
"func",
"(",
"r",
"*",
"ProquintResolver",
")",
"resolveOnceAsync",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"options",
"opts",
".",
"ResolveOpts",
")",
"<-",
"chan",
"onceResult",
"{",
"out",
":=",
"make",
"(",
"chan",
"onceResul... | // resolveOnce implements resolver. Decodes the proquint string. | [
"resolveOnce",
"implements",
"resolver",
".",
"Decodes",
"the",
"proquint",
"string",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/proquint.go#L20-L32 |
127,377 | ipfs/go-ipfs | core/coreapi/coreapi.go | NewCoreAPI | func NewCoreAPI(n *core.IpfsNode, opts ...options.ApiOption) (coreiface.CoreAPI, error) {
parentOpts, err := options.ApiOptions()
if err != nil {
return nil, err
}
return (&CoreAPI{nd: n, parentOpts: *parentOpts}).WithOptions(opts...)
} | go | func NewCoreAPI(n *core.IpfsNode, opts ...options.ApiOption) (coreiface.CoreAPI, error) {
parentOpts, err := options.ApiOptions()
if err != nil {
return nil, err
}
return (&CoreAPI{nd: n, parentOpts: *parentOpts}).WithOptions(opts...)
} | [
"func",
"NewCoreAPI",
"(",
"n",
"*",
"core",
".",
"IpfsNode",
",",
"opts",
"...",
"options",
".",
"ApiOption",
")",
"(",
"coreiface",
".",
"CoreAPI",
",",
"error",
")",
"{",
"parentOpts",
",",
"err",
":=",
"options",
".",
"ApiOptions",
"(",
")",
"\n",
... | // NewCoreAPI creates new instance of IPFS CoreAPI backed by go-ipfs Node. | [
"NewCoreAPI",
"creates",
"new",
"instance",
"of",
"IPFS",
"CoreAPI",
"backed",
"by",
"go",
"-",
"ipfs",
"Node",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/coreapi.go#L84-L91 |
127,378 | ipfs/go-ipfs | core/coreapi/coreapi.go | WithOptions | func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, error) {
settings := api.parentOpts // make sure to copy
_, err := options.ApiOptionsTo(&settings, opts...)
if err != nil {
return nil, err
}
if api.nd == nil {
return nil, errors.New("cannot apply options to api without node")
}
... | go | func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, error) {
settings := api.parentOpts // make sure to copy
_, err := options.ApiOptionsTo(&settings, opts...)
if err != nil {
return nil, err
}
if api.nd == nil {
return nil, errors.New("cannot apply options to api without node")
}
... | [
"func",
"(",
"api",
"*",
"CoreAPI",
")",
"WithOptions",
"(",
"opts",
"...",
"options",
".",
"ApiOption",
")",
"(",
"coreiface",
".",
"CoreAPI",
",",
"error",
")",
"{",
"settings",
":=",
"api",
".",
"parentOpts",
"// make sure to copy",
"\n",
"_",
",",
"e... | // WithOptions returns api with global options applied | [
"WithOptions",
"returns",
"api",
"with",
"global",
"options",
"applied"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/coreapi.go#L147-L233 |
127,379 | ipfs/go-ipfs | core/coreapi/coreapi.go | getSession | func (api *CoreAPI) getSession(ctx context.Context) *CoreAPI {
sesApi := *api
// TODO: We could also apply this to api.blocks, and compose into writable api,
// but this requires some changes in blockservice/merkledag
sesApi.dag = dag.NewReadOnlyDagService(dag.NewSession(ctx, api.dag))
return &sesApi
} | go | func (api *CoreAPI) getSession(ctx context.Context) *CoreAPI {
sesApi := *api
// TODO: We could also apply this to api.blocks, and compose into writable api,
// but this requires some changes in blockservice/merkledag
sesApi.dag = dag.NewReadOnlyDagService(dag.NewSession(ctx, api.dag))
return &sesApi
} | [
"func",
"(",
"api",
"*",
"CoreAPI",
")",
"getSession",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"CoreAPI",
"{",
"sesApi",
":=",
"*",
"api",
"\n\n",
"// TODO: We could also apply this to api.blocks, and compose into writable api,",
"// but this requires some change... | // getSession returns new api backed by the same node with a read-only session DAG | [
"getSession",
"returns",
"new",
"api",
"backed",
"by",
"the",
"same",
"node",
"with",
"a",
"read",
"-",
"only",
"session",
"DAG"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/coreapi/coreapi.go#L236-L244 |
127,380 | ipfs/go-ipfs | blocks/blockstoreutil/remove.go | RmBlocks | func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error) {
// make the channel large enough to hold any result to avoid
// blocking while holding the GCLock
out := make(chan interface{}, len(cids))
go func() {
defer close(out)
unlocker := blocks.GCLo... | go | func RmBlocks(blocks bs.GCBlockstore, pins pin.Pinner, cids []cid.Cid, opts RmBlocksOpts) (<-chan interface{}, error) {
// make the channel large enough to hold any result to avoid
// blocking while holding the GCLock
out := make(chan interface{}, len(cids))
go func() {
defer close(out)
unlocker := blocks.GCLo... | [
"func",
"RmBlocks",
"(",
"blocks",
"bs",
".",
"GCBlockstore",
",",
"pins",
"pin",
".",
"Pinner",
",",
"cids",
"[",
"]",
"cid",
".",
"Cid",
",",
"opts",
"RmBlocksOpts",
")",
"(",
"<-",
"chan",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// make th... | // RmBlocks removes the blocks provided in the cids slice.
// It returns a channel where objects of type RemovedBlock are placed, when
// not using the Quiet option. Block removal is asynchronous and will
// skip any pinned blocks. | [
"RmBlocks",
"removes",
"the",
"blocks",
"provided",
"in",
"the",
"cids",
"slice",
".",
"It",
"returns",
"a",
"channel",
"where",
"objects",
"of",
"type",
"RemovedBlock",
"are",
"placed",
"when",
"not",
"using",
"the",
"Quiet",
"option",
".",
"Block",
"remova... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/blocks/blockstoreutil/remove.go#L37-L61 |
127,381 | ipfs/go-ipfs | core/corehttp/metrics.go | MetricsScrapingOption | func MetricsScrapingOption(path string) ServeOption {
return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.Handle(path, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}))
return mux, nil
}
} | go | func MetricsScrapingOption(path string) ServeOption {
return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.Handle(path, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}))
return mux, nil
}
} | [
"func",
"MetricsScrapingOption",
"(",
"path",
"string",
")",
"ServeOption",
"{",
"return",
"func",
"(",
"n",
"*",
"core",
".",
"IpfsNode",
",",
"_",
"net",
".",
"Listener",
",",
"mux",
"*",
"http",
".",
"ServeMux",
")",
"(",
"*",
"http",
".",
"ServeMux... | // This adds the scraping endpoint which Prometheus uses to fetch metrics. | [
"This",
"adds",
"the",
"scraping",
"endpoint",
"which",
"Prometheus",
"uses",
"to",
"fetch",
"metrics",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/core/corehttp/metrics.go#L14-L19 |
127,382 | ipfs/go-ipfs | namesys/routing.go | NewIpnsResolver | func NewIpnsResolver(route routing.ValueStore) *IpnsResolver {
if route == nil {
panic("attempt to create resolver with nil routing system")
}
return &IpnsResolver{
routing: route,
}
} | go | func NewIpnsResolver(route routing.ValueStore) *IpnsResolver {
if route == nil {
panic("attempt to create resolver with nil routing system")
}
return &IpnsResolver{
routing: route,
}
} | [
"func",
"NewIpnsResolver",
"(",
"route",
"routing",
".",
"ValueStore",
")",
"*",
"IpnsResolver",
"{",
"if",
"route",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"IpnsResolver",
"{",
"routing",
":",
"route",
",",
"}"... | // NewIpnsResolver constructs a name resolver using the IPFS Routing system
// to implement SFS-like naming on top. | [
"NewIpnsResolver",
"constructs",
"a",
"name",
"resolver",
"using",
"the",
"IPFS",
"Routing",
"system",
"to",
"implement",
"SFS",
"-",
"like",
"naming",
"on",
"top",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/routing.go#L30-L37 |
127,383 | ipfs/go-ipfs | namesys/routing.go | ResolveAsync | func (r *IpnsResolver) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result {
return resolveAsync(ctx, r, name, opts.ProcessOpts(options))
} | go | func (r *IpnsResolver) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan Result {
return resolveAsync(ctx, r, name, opts.ProcessOpts(options))
} | [
"func",
"(",
"r",
"*",
"IpnsResolver",
")",
"ResolveAsync",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"options",
"...",
"opts",
".",
"ResolveOpt",
")",
"<-",
"chan",
"Result",
"{",
"return",
"resolveAsync",
"(",
"ctx",
",",
"r",
... | // ResolveAsync implements Resolver. | [
"ResolveAsync",
"implements",
"Resolver",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/routing.go#L45-L47 |
127,384 | ipfs/go-ipfs | namesys/routing.go | resolveOnceAsync | func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
out := make(chan onceResult, 1)
log.Debugf("RoutingResolver resolving %s", name)
cancel := func() {}
if options.DhtTimeout != 0 {
// Resolution must complete within the timeout
ctx, cancel = ... | go | func (r *IpnsResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
out := make(chan onceResult, 1)
log.Debugf("RoutingResolver resolving %s", name)
cancel := func() {}
if options.DhtTimeout != 0 {
// Resolution must complete within the timeout
ctx, cancel = ... | [
"func",
"(",
"r",
"*",
"IpnsResolver",
")",
"resolveOnceAsync",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"options",
"opts",
".",
"ResolveOpts",
")",
"<-",
"chan",
"onceResult",
"{",
"out",
":=",
"make",
"(",
"chan",
"onceResult",
... | // resolveOnce implements resolver. Uses the IPFS routing system to
// resolve SFS-like names. | [
"resolveOnce",
"implements",
"resolver",
".",
"Uses",
"the",
"IPFS",
"routing",
"system",
"to",
"resolve",
"SFS",
"-",
"like",
"names",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/namesys/routing.go#L51-L161 |
127,385 | ipfs/go-ipfs | repo/fsrepo/misc.go | BestKnownPath | func BestKnownPath() (string, error) {
ipfsPath := config.DefaultPathRoot
if os.Getenv(config.EnvDir) != "" {
ipfsPath = os.Getenv(config.EnvDir)
}
ipfsPath, err := homedir.Expand(ipfsPath)
if err != nil {
return "", err
}
return ipfsPath, nil
} | go | func BestKnownPath() (string, error) {
ipfsPath := config.DefaultPathRoot
if os.Getenv(config.EnvDir) != "" {
ipfsPath = os.Getenv(config.EnvDir)
}
ipfsPath, err := homedir.Expand(ipfsPath)
if err != nil {
return "", err
}
return ipfsPath, nil
} | [
"func",
"BestKnownPath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"ipfsPath",
":=",
"config",
".",
"DefaultPathRoot",
"\n",
"if",
"os",
".",
"Getenv",
"(",
"config",
".",
"EnvDir",
")",
"!=",
"\"",
"\"",
"{",
"ipfsPath",
"=",
"os",
".",
"Gete... | // BestKnownPath returns the best known fsrepo path. If the ENV override is
// present, this function returns that value. Otherwise, it returns the default
// repo path. | [
"BestKnownPath",
"returns",
"the",
"best",
"known",
"fsrepo",
"path",
".",
"If",
"the",
"ENV",
"override",
"is",
"present",
"this",
"function",
"returns",
"that",
"value",
".",
"Otherwise",
"it",
"returns",
"the",
"default",
"repo",
"path",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/repo/fsrepo/misc.go#L13-L23 |
127,386 | ipfs/go-ipfs | filestore/util.go | String | func (s Status) String() string {
switch s {
case StatusOk:
return "ok"
case StatusFileError:
return "error"
case StatusFileNotFound:
return "no-file"
case StatusFileChanged:
return "changed"
case StatusOtherError:
return "ERROR"
case StatusKeyNotFound:
return "missing"
default:
return "???"
}
} | go | func (s Status) String() string {
switch s {
case StatusOk:
return "ok"
case StatusFileError:
return "error"
case StatusFileNotFound:
return "no-file"
case StatusFileChanged:
return "changed"
case StatusOtherError:
return "ERROR"
case StatusKeyNotFound:
return "missing"
default:
return "???"
}
} | [
"func",
"(",
"s",
"Status",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"s",
"{",
"case",
"StatusOk",
":",
"return",
"\"",
"\"",
"\n",
"case",
"StatusFileError",
":",
"return",
"\"",
"\"",
"\n",
"case",
"StatusFileNotFound",
":",
"return",
"\"",
... | // String provides a human-readable representation for Status codes. | [
"String",
"provides",
"a",
"human",
"-",
"readable",
"representation",
"for",
"Status",
"codes",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/util.go#L31-L48 |
127,387 | ipfs/go-ipfs | filestore/util.go | FormatLong | func (r *ListRes) FormatLong(enc func(cid.Cid) string) string {
if enc == nil {
enc = (cid.Cid).String
}
switch {
case !r.Key.Defined():
return "<corrupt key>"
case r.FilePath == "":
return r.Key.String()
default:
return fmt.Sprintf("%-50s %6d %s %d", enc(r.Key), r.Size, r.FilePath, r.Offset)
}
} | go | func (r *ListRes) FormatLong(enc func(cid.Cid) string) string {
if enc == nil {
enc = (cid.Cid).String
}
switch {
case !r.Key.Defined():
return "<corrupt key>"
case r.FilePath == "":
return r.Key.String()
default:
return fmt.Sprintf("%-50s %6d %s %d", enc(r.Key), r.Size, r.FilePath, r.Offset)
}
} | [
"func",
"(",
"r",
"*",
"ListRes",
")",
"FormatLong",
"(",
"enc",
"func",
"(",
"cid",
".",
"Cid",
")",
"string",
")",
"string",
"{",
"if",
"enc",
"==",
"nil",
"{",
"enc",
"=",
"(",
"cid",
".",
"Cid",
")",
".",
"String",
"\n",
"}",
"\n",
"switch"... | // FormatLong returns a human readable string for a ListRes object | [
"FormatLong",
"returns",
"a",
"human",
"readable",
"string",
"for",
"a",
"ListRes",
"object"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/util.go#L70-L82 |
127,388 | ipfs/go-ipfs | filestore/util.go | Verify | func Verify(fs *Filestore, key cid.Cid) *ListRes {
return list(fs, true, key)
} | go | func Verify(fs *Filestore, key cid.Cid) *ListRes {
return list(fs, true, key)
} | [
"func",
"Verify",
"(",
"fs",
"*",
"Filestore",
",",
"key",
"cid",
".",
"Cid",
")",
"*",
"ListRes",
"{",
"return",
"list",
"(",
"fs",
",",
"true",
",",
"key",
")",
"\n",
"}"
] | // Verify fetches the block with the given key from the Filemanager
// of the given Filestore and returns a ListRes object with the information.
// Verify makes sure that the reference is valid and the block data can be
// read. | [
"Verify",
"fetches",
"the",
"block",
"with",
"the",
"given",
"key",
"from",
"the",
"Filemanager",
"of",
"the",
"given",
"Filestore",
"and",
"returns",
"a",
"ListRes",
"object",
"with",
"the",
"information",
".",
"Verify",
"makes",
"sure",
"that",
"the",
"ref... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/util.go#L107-L109 |
127,389 | ipfs/go-ipfs | filestore/util.go | VerifyAll | func VerifyAll(fs *Filestore, fileOrder bool) (func() *ListRes, error) {
if fileOrder {
return listAllFileOrder(fs, true)
}
return listAll(fs, true)
} | go | func VerifyAll(fs *Filestore, fileOrder bool) (func() *ListRes, error) {
if fileOrder {
return listAllFileOrder(fs, true)
}
return listAll(fs, true)
} | [
"func",
"VerifyAll",
"(",
"fs",
"*",
"Filestore",
",",
"fileOrder",
"bool",
")",
"(",
"func",
"(",
")",
"*",
"ListRes",
",",
"error",
")",
"{",
"if",
"fileOrder",
"{",
"return",
"listAllFileOrder",
"(",
"fs",
",",
"true",
")",
"\n",
"}",
"\n",
"retur... | // VerifyAll returns a function as an iterator which, once invoked,
// returns one by one each block in the Filestore's FileManager.
// VerifyAll checks that the reference is valid and that the block data
// can be read. | [
"VerifyAll",
"returns",
"a",
"function",
"as",
"an",
"iterator",
"which",
"once",
"invoked",
"returns",
"one",
"by",
"one",
"each",
"block",
"in",
"the",
"Filestore",
"s",
"FileManager",
".",
"VerifyAll",
"checks",
"that",
"the",
"reference",
"is",
"valid",
... | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/filestore/util.go#L115-L120 |
127,390 | ipfs/go-ipfs | plugin/loader/loader.go | NewPluginLoader | func NewPluginLoader(pluginDir string) (*PluginLoader, error) {
plMap := make(map[string]plugin.Plugin)
for _, v := range preloadPlugins {
plMap[v.Name()] = v
}
if pluginDir != "" {
newPls, err := loadDynamicPlugins(pluginDir)
if err != nil {
return nil, err
}
for _, pl := range newPls {
if ppl, o... | go | func NewPluginLoader(pluginDir string) (*PluginLoader, error) {
plMap := make(map[string]plugin.Plugin)
for _, v := range preloadPlugins {
plMap[v.Name()] = v
}
if pluginDir != "" {
newPls, err := loadDynamicPlugins(pluginDir)
if err != nil {
return nil, err
}
for _, pl := range newPls {
if ppl, o... | [
"func",
"NewPluginLoader",
"(",
"pluginDir",
"string",
")",
"(",
"*",
"PluginLoader",
",",
"error",
")",
"{",
"plMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"plugin",
".",
"Plugin",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"preloadPlugin... | // NewPluginLoader creates new plugin loader | [
"NewPluginLoader",
"creates",
"new",
"plugin",
"loader"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/plugin/loader/loader.go#L30-L61 |
127,391 | ipfs/go-ipfs | plugin/loader/loader.go | Initialize | func (loader *PluginLoader) Initialize() error {
for _, p := range loader.plugins {
err := p.Init()
if err != nil {
return err
}
}
return nil
} | go | func (loader *PluginLoader) Initialize() error {
for _, p := range loader.plugins {
err := p.Init()
if err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"loader",
"*",
"PluginLoader",
")",
"Initialize",
"(",
")",
"error",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"loader",
".",
"plugins",
"{",
"err",
":=",
"p",
".",
"Init",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"er... | // Initialize initializes all loaded plugins | [
"Initialize",
"initializes",
"all",
"loaded",
"plugins"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/plugin/loader/loader.go#L76-L85 |
127,392 | ipfs/go-ipfs | plugin/loader/loader.go | Inject | func (loader *PluginLoader) Inject() error {
for _, pl := range loader.plugins {
if pl, ok := pl.(plugin.PluginIPLD); ok {
err := injectIPLDPlugin(pl)
if err != nil {
return err
}
}
if pl, ok := pl.(plugin.PluginTracer); ok {
err := injectTracerPlugin(pl)
if err != nil {
return err
}
... | go | func (loader *PluginLoader) Inject() error {
for _, pl := range loader.plugins {
if pl, ok := pl.(plugin.PluginIPLD); ok {
err := injectIPLDPlugin(pl)
if err != nil {
return err
}
}
if pl, ok := pl.(plugin.PluginTracer); ok {
err := injectTracerPlugin(pl)
if err != nil {
return err
}
... | [
"func",
"(",
"loader",
"*",
"PluginLoader",
")",
"Inject",
"(",
")",
"error",
"{",
"for",
"_",
",",
"pl",
":=",
"range",
"loader",
".",
"plugins",
"{",
"if",
"pl",
",",
"ok",
":=",
"pl",
".",
"(",
"plugin",
".",
"PluginIPLD",
")",
";",
"ok",
"{",... | // Inject hooks all the plugins into the appropriate subsystems. | [
"Inject",
"hooks",
"all",
"the",
"plugins",
"into",
"the",
"appropriate",
"subsystems",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/plugin/loader/loader.go#L88-L110 |
127,393 | ipfs/go-ipfs | reprovide/providers.go | NewBlockstoreProvider | func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {
return func(ctx context.Context) (<-chan cid.Cid, error) {
return bstore.AllKeysChan(ctx)
}
} | go | func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {
return func(ctx context.Context) (<-chan cid.Cid, error) {
return bstore.AllKeysChan(ctx)
}
} | [
"func",
"NewBlockstoreProvider",
"(",
"bstore",
"blocks",
".",
"Blockstore",
")",
"KeyChanFunc",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"cid",
".",
"Cid",
",",
"error",
")",
"{",
"return",
"bstore",
".",
"Al... | // NewBlockstoreProvider returns key provider using bstore.AllKeysChan | [
"NewBlockstoreProvider",
"returns",
"key",
"provider",
"using",
"bstore",
".",
"AllKeysChan"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/reprovide/providers.go#L16-L20 |
127,394 | ipfs/go-ipfs | reprovide/providers.go | NewPinnedProvider | func NewPinnedProvider(onlyRoots bool) func(pinning pin.Pinner, dag ipld.DAGService) KeyChanFunc {
return func(pinning pin.Pinner, dag ipld.DAGService) KeyChanFunc {
return func(ctx context.Context) (<-chan cid.Cid, error) {
set, err := pinSet(ctx, pinning, dag, onlyRoots)
if err != nil {
return nil, err
... | go | func NewPinnedProvider(onlyRoots bool) func(pinning pin.Pinner, dag ipld.DAGService) KeyChanFunc {
return func(pinning pin.Pinner, dag ipld.DAGService) KeyChanFunc {
return func(ctx context.Context) (<-chan cid.Cid, error) {
set, err := pinSet(ctx, pinning, dag, onlyRoots)
if err != nil {
return nil, err
... | [
"func",
"NewPinnedProvider",
"(",
"onlyRoots",
"bool",
")",
"func",
"(",
"pinning",
"pin",
".",
"Pinner",
",",
"dag",
"ipld",
".",
"DAGService",
")",
"KeyChanFunc",
"{",
"return",
"func",
"(",
"pinning",
"pin",
".",
"Pinner",
",",
"dag",
"ipld",
".",
"DA... | // NewPinnedProvider returns provider supplying pinned keys | [
"NewPinnedProvider",
"returns",
"provider",
"supplying",
"pinned",
"keys"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/reprovide/providers.go#L23-L47 |
127,395 | ipfs/go-ipfs | fuse/mount/fuse.go | NewMount | func NewMount(p goprocess.Process, fsys fs.FS, mountpoint string, allow_other bool) (Mount, error) {
var conn *fuse.Conn
var err error
if allow_other {
conn, err = fuse.Mount(mountpoint, fuse.AllowOther())
} else {
conn, err = fuse.Mount(mountpoint)
}
if err != nil {
return nil, err
}
m := &mount{
mp... | go | func NewMount(p goprocess.Process, fsys fs.FS, mountpoint string, allow_other bool) (Mount, error) {
var conn *fuse.Conn
var err error
if allow_other {
conn, err = fuse.Mount(mountpoint, fuse.AllowOther())
} else {
conn, err = fuse.Mount(mountpoint)
}
if err != nil {
return nil, err
}
m := &mount{
mp... | [
"func",
"NewMount",
"(",
"p",
"goprocess",
".",
"Process",
",",
"fsys",
"fs",
".",
"FS",
",",
"mountpoint",
"string",
",",
"allow_other",
"bool",
")",
"(",
"Mount",
",",
"error",
")",
"{",
"var",
"conn",
"*",
"fuse",
".",
"Conn",
"\n",
"var",
"err",
... | // Mount mounts a fuse fs.FS at a given location, and returns a Mount instance.
// parent is a ContextGroup to bind the mount's ContextGroup to. | [
"Mount",
"mounts",
"a",
"fuse",
"fs",
".",
"FS",
"at",
"a",
"given",
"location",
"and",
"returns",
"a",
"Mount",
"instance",
".",
"parent",
"is",
"a",
"ContextGroup",
"to",
"bind",
"the",
"mount",
"s",
"ContextGroup",
"to",
"."
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/fuse/mount/fuse.go#L33-L64 |
127,396 | ipfs/go-ipfs | keystore/memkeystore.go | Has | func (mk *MemKeystore) Has(name string) (bool, error) {
_, ok := mk.keys[name]
return ok, nil
} | go | func (mk *MemKeystore) Has(name string) (bool, error) {
_, ok := mk.keys[name]
return ok, nil
} | [
"func",
"(",
"mk",
"*",
"MemKeystore",
")",
"Has",
"(",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"_",
",",
"ok",
":=",
"mk",
".",
"keys",
"[",
"name",
"]",
"\n",
"return",
"ok",
",",
"nil",
"\n",
"}"
] | // Has return whether or not a key exist in the Keystore | [
"Has",
"return",
"whether",
"or",
"not",
"a",
"key",
"exist",
"in",
"the",
"Keystore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/memkeystore.go#L16-L19 |
127,397 | ipfs/go-ipfs | keystore/memkeystore.go | Put | func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
if err := validateName(name); err != nil {
return err
}
_, ok := mk.keys[name]
if ok {
return ErrKeyExists
}
mk.keys[name] = k
return nil
} | go | func (mk *MemKeystore) Put(name string, k ci.PrivKey) error {
if err := validateName(name); err != nil {
return err
}
_, ok := mk.keys[name]
if ok {
return ErrKeyExists
}
mk.keys[name] = k
return nil
} | [
"func",
"(",
"mk",
"*",
"MemKeystore",
")",
"Put",
"(",
"name",
"string",
",",
"k",
"ci",
".",
"PrivKey",
")",
"error",
"{",
"if",
"err",
":=",
"validateName",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"_... | // Put store a key in the Keystore | [
"Put",
"store",
"a",
"key",
"in",
"the",
"Keystore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/memkeystore.go#L22-L34 |
127,398 | ipfs/go-ipfs | keystore/memkeystore.go | Get | func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
if err := validateName(name); err != nil {
return nil, err
}
k, ok := mk.keys[name]
if !ok {
return nil, ErrNoSuchKey
}
return k, nil
} | go | func (mk *MemKeystore) Get(name string) (ci.PrivKey, error) {
if err := validateName(name); err != nil {
return nil, err
}
k, ok := mk.keys[name]
if !ok {
return nil, ErrNoSuchKey
}
return k, nil
} | [
"func",
"(",
"mk",
"*",
"MemKeystore",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"ci",
".",
"PrivKey",
",",
"error",
")",
"{",
"if",
"err",
":=",
"validateName",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n"... | // Get retrieve a key from the Keystore | [
"Get",
"retrieve",
"a",
"key",
"from",
"the",
"Keystore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/memkeystore.go#L37-L48 |
127,399 | ipfs/go-ipfs | keystore/memkeystore.go | Delete | func (mk *MemKeystore) Delete(name string) error {
if err := validateName(name); err != nil {
return err
}
delete(mk.keys, name)
return nil
} | go | func (mk *MemKeystore) Delete(name string) error {
if err := validateName(name); err != nil {
return err
}
delete(mk.keys, name)
return nil
} | [
"func",
"(",
"mk",
"*",
"MemKeystore",
")",
"Delete",
"(",
"name",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"validateName",
"(",
"name",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"delete",
"(",
"mk",
".",
"keys",... | // Delete remove a key from the Keystore | [
"Delete",
"remove",
"a",
"key",
"from",
"the",
"Keystore"
] | 5fd5d444796d4936166f3a38dc066fda7183399c | https://github.com/ipfs/go-ipfs/blob/5fd5d444796d4936166f3a38dc066fda7183399c/keystore/memkeystore.go#L51-L58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.