id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
22,400 | apache/qpid-proton | go/src/qpid.apache.org/electron/session.go | Accept | func (in *IncomingSession) Accept() Endpoint {
return in.accept(func() Endpoint {
return newSession(in.h.connection, in.pSession, IncomingCapacity(in.incomingCapacity), OutgoingWindow(in.outgoingWindow))
})
} | go | func (in *IncomingSession) Accept() Endpoint {
return in.accept(func() Endpoint {
return newSession(in.h.connection, in.pSession, IncomingCapacity(in.incomingCapacity), OutgoingWindow(in.outgoingWindow))
})
} | [
"func",
"(",
"in",
"*",
"IncomingSession",
")",
"Accept",
"(",
")",
"Endpoint",
"{",
"return",
"in",
".",
"accept",
"(",
"func",
"(",
")",
"Endpoint",
"{",
"return",
"newSession",
"(",
"in",
".",
"h",
".",
"connection",
",",
"in",
".",
"pSession",
",... | // Accept an incoming session endpoint. | [
"Accept",
"an",
"incoming",
"session",
"endpoint",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/session.go#L135-L139 |
22,401 | apache/qpid-proton | go/src/qpid.apache.org/amqp/url.go | splitHostPort | func splitHostPort(hostport string) (string, string, error) {
if hostport == "" {
return "", "", nil
}
if hostport[0] == '[' {
// There must be a matching ']' as already validated
if l := strings.LastIndex(hostport, "]"); len(hostport) == l+1 {
// trim off '[' and ']'
return hostport[1:l], "", nil
}
}... | go | func splitHostPort(hostport string) (string, string, error) {
if hostport == "" {
return "", "", nil
}
if hostport[0] == '[' {
// There must be a matching ']' as already validated
if l := strings.LastIndex(hostport, "]"); len(hostport) == l+1 {
// trim off '[' and ']'
return hostport[1:l], "", nil
}
}... | [
"func",
"splitHostPort",
"(",
"hostport",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"if",
"hostport",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n",
"if",
"hostport",
"[",
"0",
... | // The way this is used it can only get a hostport already validated by
// the URL parser, so this means we can skip some error checks | [
"The",
"way",
"this",
"is",
"used",
"it",
"can",
"only",
"get",
"a",
"hostport",
"already",
"validated",
"by",
"the",
"URL",
"parser",
"so",
"this",
"means",
"we",
"can",
"skip",
"some",
"error",
"checks"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/url.go#L37-L51 |
22,402 | apache/qpid-proton | go/src/qpid.apache.org/proton/message.go | Message | func (delivery Delivery) Message() (amqp.Message, error) {
var err error
bytes, err := delivery.MessageBytes()
if err == nil {
m := amqp.NewMessage()
err = m.Decode(bytes)
return m, err
}
return nil, err
} | go | func (delivery Delivery) Message() (amqp.Message, error) {
var err error
bytes, err := delivery.MessageBytes()
if err == nil {
m := amqp.NewMessage()
err = m.Decode(bytes)
return m, err
}
return nil, err
} | [
"func",
"(",
"delivery",
"Delivery",
")",
"Message",
"(",
")",
"(",
"amqp",
".",
"Message",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"bytes",
",",
"err",
":=",
"delivery",
".",
"MessageBytes",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"... | // Message decodes the message contained in a delivery.
//
// Must be called in the correct link context with this delivery as the current message,
// handling an MMessage event is always a safe context to call this function.
//
// Will return an error if message is incomplete or not current. | [
"Message",
"decodes",
"the",
"message",
"contained",
"in",
"a",
"delivery",
".",
"Must",
"be",
"called",
"in",
"the",
"correct",
"link",
"context",
"with",
"this",
"delivery",
"as",
"the",
"current",
"message",
"handling",
"an",
"MMessage",
"event",
"is",
"a... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/message.go#L45-L54 |
22,403 | apache/qpid-proton | go/src/qpid.apache.org/proton/message.go | MessageBytes | func (delivery Delivery) MessageBytes() ([]byte, error) {
if !delivery.Readable() {
return nil, fmt.Errorf("delivery is not readable")
}
if delivery.Partial() {
return nil, fmt.Errorf("delivery has partial message")
}
data := make([]byte, delivery.Pending())
result := delivery.Link().Recv(data)
if result != ... | go | func (delivery Delivery) MessageBytes() ([]byte, error) {
if !delivery.Readable() {
return nil, fmt.Errorf("delivery is not readable")
}
if delivery.Partial() {
return nil, fmt.Errorf("delivery has partial message")
}
data := make([]byte, delivery.Pending())
result := delivery.Link().Recv(data)
if result != ... | [
"func",
"(",
"delivery",
"Delivery",
")",
"MessageBytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"!",
"delivery",
".",
"Readable",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",... | // MessageBytes extracts the raw message bytes contained in a delivery.
//
// Must be called in the correct link context with this delivery as the current message,
// handling an MMessage event is always a safe context to call this function.
//
// Will return an error if message is incomplete or not current. | [
"MessageBytes",
"extracts",
"the",
"raw",
"message",
"bytes",
"contained",
"in",
"a",
"delivery",
".",
"Must",
"be",
"called",
"in",
"the",
"correct",
"link",
"context",
"with",
"this",
"delivery",
"as",
"the",
"current",
"message",
"handling",
"an",
"MMessage... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/message.go#L62-L75 |
22,404 | apache/qpid-proton | go/src/qpid.apache.org/proton/message.go | Send | func (link Link) Send(m amqp.Message) (Delivery, error) {
bytes, err := m.Encode(nil)
if err != nil {
return Delivery{}, err
}
d, err := link.SendMessageBytes(bytes)
return d, err
} | go | func (link Link) Send(m amqp.Message) (Delivery, error) {
bytes, err := m.Encode(nil)
if err != nil {
return Delivery{}, err
}
d, err := link.SendMessageBytes(bytes)
return d, err
} | [
"func",
"(",
"link",
"Link",
")",
"Send",
"(",
"m",
"amqp",
".",
"Message",
")",
"(",
"Delivery",
",",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"m",
".",
"Encode",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Delivery",
... | // Send sends a amqp.Message over a Link.
// Returns a Delivery that can be use to determine the outcome of the message. | [
"Send",
"sends",
"a",
"amqp",
".",
"Message",
"over",
"a",
"Link",
".",
"Returns",
"a",
"Delivery",
"that",
"can",
"be",
"use",
"to",
"determine",
"the",
"outcome",
"of",
"the",
"message",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/message.go#L86-L93 |
22,405 | apache/qpid-proton | go/src/qpid.apache.org/proton/message.go | SendMessageBytes | func (link Link) SendMessageBytes(bytes []byte) (Delivery, error) {
if !link.IsSender() {
return Delivery{}, fmt.Errorf("attempt to send message on receiving link")
}
delivery := link.Delivery(nextTag())
result := link.SendBytes(bytes)
link.Advance()
if result != len(bytes) {
if result < 0 {
return deliver... | go | func (link Link) SendMessageBytes(bytes []byte) (Delivery, error) {
if !link.IsSender() {
return Delivery{}, fmt.Errorf("attempt to send message on receiving link")
}
delivery := link.Delivery(nextTag())
result := link.SendBytes(bytes)
link.Advance()
if result != len(bytes) {
if result < 0 {
return deliver... | [
"func",
"(",
"link",
"Link",
")",
"SendMessageBytes",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"Delivery",
",",
"error",
")",
"{",
"if",
"!",
"link",
".",
"IsSender",
"(",
")",
"{",
"return",
"Delivery",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
... | // SendMessageBytes sends encoded bytes of an amqp.Message over a Link.
// Returns a Delivery that can be use to determine the outcome of the message. | [
"SendMessageBytes",
"sends",
"encoded",
"bytes",
"of",
"an",
"amqp",
".",
"Message",
"over",
"a",
"Link",
".",
"Returns",
"a",
"Delivery",
"that",
"can",
"be",
"use",
"to",
"determine",
"the",
"outcome",
"of",
"the",
"message",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/message.go#L97-L115 |
22,406 | apache/qpid-proton | go/src/qpid.apache.org/electron/time.go | After | func After(timeout time.Duration) <-chan time.Time {
if timeout == Forever {
return nil
} else {
return time.After(timeout)
}
} | go | func After(timeout time.Duration) <-chan time.Time {
if timeout == Forever {
return nil
} else {
return time.After(timeout)
}
} | [
"func",
"After",
"(",
"timeout",
"time",
".",
"Duration",
")",
"<-",
"chan",
"time",
".",
"Time",
"{",
"if",
"timeout",
"==",
"Forever",
"{",
"return",
"nil",
"\n",
"}",
"else",
"{",
"return",
"time",
".",
"After",
"(",
"timeout",
")",
"\n",
"}",
"... | // After is like time.After but returns a nil channel if timeout == Forever
// since selecting on a nil channel will never return. | [
"After",
"is",
"like",
"time",
".",
"After",
"but",
"returns",
"a",
"nil",
"channel",
"if",
"timeout",
"==",
"Forever",
"since",
"selecting",
"on",
"a",
"nil",
"channel",
"will",
"never",
"return",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/time.go#L77-L83 |
22,407 | apache/qpid-proton | go/src/qpid.apache.org/electron/endpoint.go | localClose | func localClose(ep proton.Endpoint, err error) {
if ep.State().LocalActive() {
proton.CloseError(ep, err)
}
} | go | func localClose(ep proton.Endpoint, err error) {
if ep.State().LocalActive() {
proton.CloseError(ep, err)
}
} | [
"func",
"localClose",
"(",
"ep",
"proton",
".",
"Endpoint",
",",
"err",
"error",
")",
"{",
"if",
"ep",
".",
"State",
"(",
")",
".",
"LocalActive",
"(",
")",
"{",
"proton",
".",
"CloseError",
"(",
"ep",
",",
"err",
")",
"\n",
"}",
"\n",
"}"
] | // Call in proton goroutine to initiate closing an endpoint locally
// handler will complete the close when remote end closes. | [
"Call",
"in",
"proton",
"goroutine",
"to",
"initiate",
"closing",
"an",
"endpoint",
"locally",
"handler",
"will",
"complete",
"the",
"close",
"when",
"remote",
"end",
"closes",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/endpoint.go#L135-L139 |
22,408 | apache/qpid-proton | go/src/qpid.apache.org/electron/endpoint.go | accept | func (in *incoming) accept(f func() Endpoint) Endpoint {
done := make(chan Endpoint)
in.acceptCh <- func() error {
ep := f()
done <- ep
return nil
}
return <-done
} | go | func (in *incoming) accept(f func() Endpoint) Endpoint {
done := make(chan Endpoint)
in.acceptCh <- func() error {
ep := f()
done <- ep
return nil
}
return <-done
} | [
"func",
"(",
"in",
"*",
"incoming",
")",
"accept",
"(",
"f",
"func",
"(",
")",
"Endpoint",
")",
"Endpoint",
"{",
"done",
":=",
"make",
"(",
"chan",
"Endpoint",
")",
"\n",
"in",
".",
"acceptCh",
"<-",
"func",
"(",
")",
"error",
"{",
"ep",
":=",
"f... | // Called in app goroutine to send an accept function to proton and return the resulting endpoint. | [
"Called",
"in",
"app",
"goroutine",
"to",
"send",
"an",
"accept",
"function",
"to",
"proton",
"and",
"return",
"the",
"resulting",
"endpoint",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/endpoint.go#L180-L188 |
22,409 | apache/qpid-proton | go/src/qpid.apache.org/amqp/message.go | NewMessageCopy | func NewMessageCopy(m Message) Message {
m2 := NewMessage()
m2.Copy(m)
return m2
} | go | func NewMessageCopy(m Message) Message {
m2 := NewMessage()
m2.Copy(m)
return m2
} | [
"func",
"NewMessageCopy",
"(",
"m",
"Message",
")",
"Message",
"{",
"m2",
":=",
"NewMessage",
"(",
")",
"\n",
"m2",
".",
"Copy",
"(",
"m",
")",
"\n",
"return",
"m2",
"\n",
"}"
] | // NewMessageCopy creates a copy of an existing message. | [
"NewMessageCopy",
"creates",
"a",
"copy",
"of",
"an",
"existing",
"message",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/message.go#L202-L206 |
22,410 | apache/qpid-proton | go/src/qpid.apache.org/amqp/message.go | Copy | func (m *message) Copy(x Message) error {
var mc MessageCodec
bytes, err := mc.Encode(x, nil)
if err == nil {
err = mc.Decode(m, bytes)
}
return err
} | go | func (m *message) Copy(x Message) error {
var mc MessageCodec
bytes, err := mc.Encode(x, nil)
if err == nil {
err = mc.Decode(m, bytes)
}
return err
} | [
"func",
"(",
"m",
"*",
"message",
")",
"Copy",
"(",
"x",
"Message",
")",
"error",
"{",
"var",
"mc",
"MessageCodec",
"\n",
"bytes",
",",
"err",
":=",
"mc",
".",
"Encode",
"(",
"x",
",",
"nil",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"err",
"="... | // Copy makes a deep copy of message x | [
"Copy",
"makes",
"a",
"deep",
"copy",
"of",
"message",
"x"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/message.go#L212-L219 |
22,411 | apache/qpid-proton | go/src/qpid.apache.org/amqp/message.go | Encode | func (mc *MessageCodec) Encode(m Message, buffer []byte) ([]byte, error) {
pn := mc.pnMessage()
m.(*message).put(pn)
encode := func(buf []byte) ([]byte, error) {
len := cLen(buf)
result := C.pn_message_encode(pn, cPtr(buf), &len)
switch {
case result == C.PN_OVERFLOW:
return buf, overflow
case result < ... | go | func (mc *MessageCodec) Encode(m Message, buffer []byte) ([]byte, error) {
pn := mc.pnMessage()
m.(*message).put(pn)
encode := func(buf []byte) ([]byte, error) {
len := cLen(buf)
result := C.pn_message_encode(pn, cPtr(buf), &len)
switch {
case result == C.PN_OVERFLOW:
return buf, overflow
case result < ... | [
"func",
"(",
"mc",
"*",
"MessageCodec",
")",
"Encode",
"(",
"m",
"Message",
",",
"buffer",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pn",
":=",
"mc",
".",
"pnMessage",
"(",
")",
"\n",
"m",
".",
"(",
"*",
"message",
... | // Encode m using buffer. Return the final buffer used to hold m,
// may be different if the initial buffer was not large enough. | [
"Encode",
"m",
"using",
"buffer",
".",
"Return",
"the",
"final",
"buffer",
"used",
"to",
"hold",
"m",
"may",
"be",
"different",
"if",
"the",
"initial",
"buffer",
"was",
"not",
"large",
"enough",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/message.go#L377-L393 |
22,412 | apache/qpid-proton | go/src/qpid.apache.org/amqp/message.go | String | func (m *message) String() string {
var b stringBuilder
b.WriteString("Message{")
b.field("address", m.address, isEmpty)
b.field("durable", m.durable, isZero)
// Priority has weird default
b.field("priority", m.priority, func(v interface{}) bool { return v.(uint8) == 4 })
b.field("ttl", m.ttl, isZero)
b.field("... | go | func (m *message) String() string {
var b stringBuilder
b.WriteString("Message{")
b.field("address", m.address, isEmpty)
b.field("durable", m.durable, isZero)
// Priority has weird default
b.field("priority", m.priority, func(v interface{}) bool { return v.(uint8) == 4 })
b.field("ttl", m.ttl, isZero)
b.field("... | [
"func",
"(",
"m",
"*",
"message",
")",
"String",
"(",
")",
"string",
"{",
"var",
"b",
"stringBuilder",
"\n",
"b",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"address",
",",
"isEmpty",
")",
... | // Human-readable string describing message.
// Includes only message fields with non-default values. | [
"Human",
"-",
"readable",
"string",
"describing",
"message",
".",
"Includes",
"only",
"message",
"fields",
"with",
"non",
"-",
"default",
"values",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/message.go#L426-L455 |
22,413 | apache/qpid-proton | go/src/qpid.apache.org/amqp/message.go | newAnnotations | func newAnnotations(in map[string]interface{}) (out map[AnnotationKey]interface{}) {
if len(in) == 0 {
return nil
}
out = make(map[AnnotationKey]interface{})
for k, v := range in {
out[AnnotationKeyString(k)] = v
}
return
} | go | func newAnnotations(in map[string]interface{}) (out map[AnnotationKey]interface{}) {
if len(in) == 0 {
return nil
}
out = make(map[AnnotationKey]interface{})
for k, v := range in {
out[AnnotationKeyString(k)] = v
}
return
} | [
"func",
"newAnnotations",
"(",
"in",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"(",
"out",
"map",
"[",
"AnnotationKey",
"]",
"interface",
"{",
"}",
")",
"{",
"if",
"len",
"(",
"in",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\... | // Convert old string-keyed annotations to an AnnotationKey map | [
"Convert",
"old",
"string",
"-",
"keyed",
"annotations",
"to",
"an",
"AnnotationKey",
"map"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/message.go#L586-L595 |
22,414 | apache/qpid-proton | go/src/qpid.apache.org/amqp/types.go | GoString | func (m Map) GoString() string {
out := &bytes.Buffer{}
fmt.Fprintf(out, "%T{", m)
i := len(m)
for k, v := range m {
fmt.Fprintf(out, "%T(%#v): %T(%#v)", k, k, v, v)
i--
if i > 0 {
fmt.Fprint(out, ", ")
}
}
fmt.Fprint(out, "}")
return out.String()
} | go | func (m Map) GoString() string {
out := &bytes.Buffer{}
fmt.Fprintf(out, "%T{", m)
i := len(m)
for k, v := range m {
fmt.Fprintf(out, "%T(%#v): %T(%#v)", k, k, v, v)
i--
if i > 0 {
fmt.Fprint(out, ", ")
}
}
fmt.Fprint(out, "}")
return out.String()
} | [
"func",
"(",
"m",
"Map",
")",
"GoString",
"(",
")",
"string",
"{",
"out",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"out",
",",
"\"",
"\"",
",",
"m",
")",
"\n",
"i",
":=",
"len",
"(",
"m",
")",
"\n",
"fo... | // GoString for Map prints values with their types, useful for debugging. | [
"GoString",
"for",
"Map",
"prints",
"values",
"with",
"their",
"types",
"useful",
"for",
"debugging",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/types.go#L136-L149 |
22,415 | apache/qpid-proton | go/src/qpid.apache.org/amqp/types.go | GoString | func (l List) GoString() string {
out := &bytes.Buffer{}
fmt.Fprintf(out, "%T{", l)
for i := 0; i < len(l); i++ {
fmt.Fprintf(out, "%T(%#v)", l[i], l[i])
if i == len(l)-1 {
fmt.Fprint(out, ", ")
}
}
fmt.Fprint(out, "}")
return out.String()
} | go | func (l List) GoString() string {
out := &bytes.Buffer{}
fmt.Fprintf(out, "%T{", l)
for i := 0; i < len(l); i++ {
fmt.Fprintf(out, "%T(%#v)", l[i], l[i])
if i == len(l)-1 {
fmt.Fprint(out, ", ")
}
}
fmt.Fprint(out, "}")
return out.String()
} | [
"func",
"(",
"l",
"List",
")",
"GoString",
"(",
")",
"string",
"{",
"out",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
"out",
",",
"\"",
"\"",
",",
"l",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"le... | // GoString for List prints values with their types, useful for debugging. | [
"GoString",
"for",
"List",
"prints",
"values",
"with",
"their",
"types",
"useful",
"for",
"debugging",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/types.go#L152-L163 |
22,416 | apache/qpid-proton | go/src/qpid.apache.org/amqp/types.go | pnTime | func pnTime(t time.Time) C.pn_timestamp_t {
if t.IsZero() {
return C.pn_timestamp_t(0)
}
return C.pn_timestamp_t(t.UnixNano() / int64(time.Millisecond))
} | go | func pnTime(t time.Time) C.pn_timestamp_t {
if t.IsZero() {
return C.pn_timestamp_t(0)
}
return C.pn_timestamp_t(t.UnixNano() / int64(time.Millisecond))
} | [
"func",
"pnTime",
"(",
"t",
"time",
".",
"Time",
")",
"C",
".",
"pn_timestamp_t",
"{",
"if",
"t",
".",
"IsZero",
"(",
")",
"{",
"return",
"C",
".",
"pn_timestamp_t",
"(",
"0",
")",
"\n",
"}",
"\n",
"return",
"C",
".",
"pn_timestamp_t",
"(",
"t",
... | // pnTime converts Go time.Time to Proton millisecond Unix time.
// Take care to convert zero values to zero values. | [
"pnTime",
"converts",
"Go",
"time",
".",
"Time",
"to",
"Proton",
"millisecond",
"Unix",
"time",
".",
"Take",
"care",
"to",
"convert",
"zero",
"values",
"to",
"zero",
"values",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/types.go#L167-L172 |
22,417 | apache/qpid-proton | go/src/qpid.apache.org/amqp/types.go | goTime | func goTime(t C.pn_timestamp_t) time.Time {
if t == 0 {
return time.Time{}
}
return time.Unix(0, int64(t)*int64(time.Millisecond))
} | go | func goTime(t C.pn_timestamp_t) time.Time {
if t == 0 {
return time.Time{}
}
return time.Unix(0, int64(t)*int64(time.Millisecond))
} | [
"func",
"goTime",
"(",
"t",
"C",
".",
"pn_timestamp_t",
")",
"time",
".",
"Time",
"{",
"if",
"t",
"==",
"0",
"{",
"return",
"time",
".",
"Time",
"{",
"}",
"\n",
"}",
"\n",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"int64",
"(",
"t",
")",
... | // goTime converts a pn_timestamp_t to a Go time.Time.
// Take care to convert zero values to zero values. | [
"goTime",
"converts",
"a",
"pn_timestamp_t",
"to",
"a",
"Go",
"time",
".",
"Time",
".",
"Take",
"care",
"to",
"convert",
"zero",
"values",
"to",
"zero",
"values",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/types.go#L176-L181 |
22,418 | apache/qpid-proton | go/src/qpid.apache.org/amqp/error.go | Errorf | func Errorf(name, format string, arg ...interface{}) Error {
return Error{name, fmt.Sprintf(format, arg...)}
} | go | func Errorf(name, format string, arg ...interface{}) Error {
return Error{name, fmt.Sprintf(format, arg...)}
} | [
"func",
"Errorf",
"(",
"name",
",",
"format",
"string",
",",
"arg",
"...",
"interface",
"{",
"}",
")",
"Error",
"{",
"return",
"Error",
"{",
"name",
",",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"arg",
"...",
")",
"}",
"\n",
"}"
] | // Errorf makes a Error with name and formatted description as per fmt.Sprintf | [
"Errorf",
"makes",
"a",
"Error",
"with",
"name",
"and",
"formatted",
"description",
"as",
"per",
"fmt",
".",
"Sprintf"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/error.go#L44-L46 |
22,419 | apache/qpid-proton | go/examples/electron/broker.go | run | func (b *broker) run() error {
listener, err := net.Listen("tcp", *addr)
if err != nil {
return err
}
defer listener.Close()
fmt.Printf("Listening on %v\n", listener.Addr())
go b.acknowledgements() // Handles acknowledgements for all connections.
// Start a goroutine for each new connections
for {
c, err ... | go | func (b *broker) run() error {
listener, err := net.Listen("tcp", *addr)
if err != nil {
return err
}
defer listener.Close()
fmt.Printf("Listening on %v\n", listener.Addr())
go b.acknowledgements() // Handles acknowledgements for all connections.
// Start a goroutine for each new connections
for {
c, err ... | [
"func",
"(",
"b",
"*",
"broker",
")",
"run",
"(",
")",
"error",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"*",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"... | // run listens for incoming net.Conn connections and starts an electron.Connection for each one. | [
"run",
"listens",
"for",
"incoming",
"net",
".",
"Conn",
"connections",
"and",
"starts",
"an",
"electron",
".",
"Connection",
"for",
"each",
"one",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/electron/broker.go#L91-L112 |
22,420 | apache/qpid-proton | go/examples/electron/broker.go | receiver | func (c *connection) receiver(receiver electron.Receiver) {
q := c.broker.queues.Get(receiver.Target())
for {
if rm, err := receiver.Receive(); err == nil {
debugf("%v: received %v", receiver, rm.Message.Body())
q <- rm.Message
rm.Accept()
} else {
debugf("%v error: %v", receiver, err)
break
}
}... | go | func (c *connection) receiver(receiver electron.Receiver) {
q := c.broker.queues.Get(receiver.Target())
for {
if rm, err := receiver.Receive(); err == nil {
debugf("%v: received %v", receiver, rm.Message.Body())
q <- rm.Message
rm.Accept()
} else {
debugf("%v error: %v", receiver, err)
break
}
}... | [
"func",
"(",
"c",
"*",
"connection",
")",
"receiver",
"(",
"receiver",
"electron",
".",
"Receiver",
")",
"{",
"q",
":=",
"c",
".",
"broker",
".",
"queues",
".",
"Get",
"(",
"receiver",
".",
"Target",
"(",
")",
")",
"\n",
"for",
"{",
"if",
"rm",
"... | // receiver receives messages and pushes to a queue. | [
"receiver",
"receives",
"messages",
"and",
"pushes",
"to",
"a",
"queue",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/electron/broker.go#L146-L158 |
22,421 | apache/qpid-proton | go/examples/electron/broker.go | sender | func (c *connection) sender(sender electron.Sender) {
q := c.broker.queues.Get(sender.Source())
for {
if sender.Error() != nil {
debugf("%v closed: %v", sender, sender.Error())
return
}
select {
case m := <-q:
debugf("%v: sent %v", sender, m.Body())
sm := sentMessage{m, q}
c.broker.sent <- sm ... | go | func (c *connection) sender(sender electron.Sender) {
q := c.broker.queues.Get(sender.Source())
for {
if sender.Error() != nil {
debugf("%v closed: %v", sender, sender.Error())
return
}
select {
case m := <-q:
debugf("%v: sent %v", sender, m.Body())
sm := sentMessage{m, q}
c.broker.sent <- sm ... | [
"func",
"(",
"c",
"*",
"connection",
")",
"sender",
"(",
"sender",
"electron",
".",
"Sender",
")",
"{",
"q",
":=",
"c",
".",
"broker",
".",
"queues",
".",
"Get",
"(",
"sender",
".",
"Source",
"(",
")",
")",
"\n",
"for",
"{",
"if",
"sender",
".",
... | // sender pops messages from a queue and sends them. | [
"sender",
"pops",
"messages",
"from",
"a",
"queue",
"and",
"sends",
"them",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/electron/broker.go#L161-L180 |
22,422 | apache/qpid-proton | go/examples/electron/broker.go | acknowledgements | func (b *broker) acknowledgements() {
sentMap := make(map[sentMessage]bool)
for {
select {
case sm, ok := <-b.sent: // A local sender records that it has sent a message.
if ok {
sentMap[sm] = true
} else {
return // Closed
}
case outcome := <-b.acks: // The message outcome is available
sm :=... | go | func (b *broker) acknowledgements() {
sentMap := make(map[sentMessage]bool)
for {
select {
case sm, ok := <-b.sent: // A local sender records that it has sent a message.
if ok {
sentMap[sm] = true
} else {
return // Closed
}
case outcome := <-b.acks: // The message outcome is available
sm :=... | [
"func",
"(",
"b",
"*",
"broker",
")",
"acknowledgements",
"(",
")",
"{",
"sentMap",
":=",
"make",
"(",
"map",
"[",
"sentMessage",
"]",
"bool",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"sm",
",",
"ok",
":=",
"<-",
"b",
".",
"sent",
":",
"// A... | // acknowledgements keeps track of sent messages and receives outcomes.
//
// We could have handled outcomes separately per-connection, per-sender or even
// per-message. Message outcomes are returned via channels defined by the user
// so they can be grouped in any way that suits the application. | [
"acknowledgements",
"keeps",
"track",
"of",
"sent",
"messages",
"and",
"receives",
"outcomes",
".",
"We",
"could",
"have",
"handled",
"outcomes",
"separately",
"per",
"-",
"connection",
"per",
"-",
"sender",
"or",
"even",
"per",
"-",
"message",
".",
"Message",... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/electron/broker.go#L187-L206 |
22,423 | apache/qpid-proton | go/examples/electron/broker.go | PutBack | func (q queue) PutBack(m amqp.Message) {
select {
case q <- m:
default:
// Not an efficient implementation but ensures we don't block the caller.
go func() { q <- m }()
}
} | go | func (q queue) PutBack(m amqp.Message) {
select {
case q <- m:
default:
// Not an efficient implementation but ensures we don't block the caller.
go func() { q <- m }()
}
} | [
"func",
"(",
"q",
"queue",
")",
"PutBack",
"(",
"m",
"amqp",
".",
"Message",
")",
"{",
"select",
"{",
"case",
"q",
"<-",
"m",
":",
"default",
":",
"// Not an efficient implementation but ensures we don't block the caller.",
"go",
"func",
"(",
")",
"{",
"q",
... | // Put a message back on the queue, does not block. | [
"Put",
"a",
"message",
"back",
"on",
"the",
"queue",
"does",
"not",
"block",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/electron/broker.go#L212-L219 |
22,424 | apache/qpid-proton | go/examples/electron/broker.go | Get | func (qs *queues) Get(name string) queue {
qs.lock.Lock()
defer qs.lock.Unlock()
q := qs.m[name]
if q == nil {
q = make(queue, qs.queueSize)
qs.m[name] = q
}
return q
} | go | func (qs *queues) Get(name string) queue {
qs.lock.Lock()
defer qs.lock.Unlock()
q := qs.m[name]
if q == nil {
q = make(queue, qs.queueSize)
qs.m[name] = q
}
return q
} | [
"func",
"(",
"qs",
"*",
"queues",
")",
"Get",
"(",
"name",
"string",
")",
"queue",
"{",
"qs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"qs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"q",
":=",
"qs",
".",
"m",
"[",
"name",
"]",
... | // Create a queue if not found. | [
"Create",
"a",
"queue",
"if",
"not",
"found",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/electron/broker.go#L233-L242 |
22,425 | apache/qpid-proton | go/src/qpid.apache.org/electron/link.go | AtMostOnce | func AtMostOnce() LinkOption {
return func(l *linkSettings) {
SndSettle(SndSettled)(l)
RcvSettle(RcvFirst)(l)
}
} | go | func AtMostOnce() LinkOption {
return func(l *linkSettings) {
SndSettle(SndSettled)(l)
RcvSettle(RcvFirst)(l)
}
} | [
"func",
"AtMostOnce",
"(",
")",
"LinkOption",
"{",
"return",
"func",
"(",
"l",
"*",
"linkSettings",
")",
"{",
"SndSettle",
"(",
"SndSettled",
")",
"(",
"l",
")",
"\n",
"RcvSettle",
"(",
"RcvFirst",
")",
"(",
"l",
")",
"\n",
"}",
"\n",
"}"
] | // AtMostOnce returns a LinkOption that sets "fire and forget" mode, messages
// are sent but no acknowledgment is received, messages can be lost if there is
// a network failure. Sets SndSettleMode=SendSettled and RcvSettleMode=RcvFirst | [
"AtMostOnce",
"returns",
"a",
"LinkOption",
"that",
"sets",
"fire",
"and",
"forget",
"mode",
"messages",
"are",
"sent",
"but",
"no",
"acknowledgment",
"is",
"received",
"messages",
"can",
"be",
"lost",
"if",
"there",
"is",
"a",
"network",
"failure",
".",
"Se... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/link.go#L104-L109 |
22,426 | apache/qpid-proton | go/src/qpid.apache.org/electron/link.go | AtLeastOnce | func AtLeastOnce() LinkOption {
return func(l *linkSettings) {
SndSettle(SndUnsettled)(l)
RcvSettle(RcvFirst)(l)
}
} | go | func AtLeastOnce() LinkOption {
return func(l *linkSettings) {
SndSettle(SndUnsettled)(l)
RcvSettle(RcvFirst)(l)
}
} | [
"func",
"AtLeastOnce",
"(",
")",
"LinkOption",
"{",
"return",
"func",
"(",
"l",
"*",
"linkSettings",
")",
"{",
"SndSettle",
"(",
"SndUnsettled",
")",
"(",
"l",
")",
"\n",
"RcvSettle",
"(",
"RcvFirst",
")",
"(",
"l",
")",
"\n",
"}",
"\n",
"}"
] | // AtLeastOnce returns a LinkOption that requests acknowledgment for every
// message, acknowledgment indicates the message was definitely received. In the
// event of a failure, unacknowledged messages can be re-sent but there is a
// chance that the message will be received twice in this case. Sets
// SndSettleMode=... | [
"AtLeastOnce",
"returns",
"a",
"LinkOption",
"that",
"requests",
"acknowledgment",
"for",
"every",
"message",
"acknowledgment",
"indicates",
"the",
"message",
"was",
"definitely",
"received",
".",
"In",
"the",
"event",
"of",
"a",
"failure",
"unacknowledged",
"messag... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/link.go#L116-L121 |
22,427 | apache/qpid-proton | go/src/qpid.apache.org/electron/link.go | Filter | func Filter(m map[amqp.Symbol]interface{}) LinkOption {
return func(l *linkSettings) { l.filter = m }
} | go | func Filter(m map[amqp.Symbol]interface{}) LinkOption {
return func(l *linkSettings) { l.filter = m }
} | [
"func",
"Filter",
"(",
"m",
"map",
"[",
"amqp",
".",
"Symbol",
"]",
"interface",
"{",
"}",
")",
"LinkOption",
"{",
"return",
"func",
"(",
"l",
"*",
"linkSettings",
")",
"{",
"l",
".",
"filter",
"=",
"m",
"}",
"\n",
"}"
] | // Filter returns a LinkOption that sets a filter. | [
"Filter",
"returns",
"a",
"LinkOption",
"that",
"sets",
"a",
"filter",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/link.go#L124-L126 |
22,428 | apache/qpid-proton | go/src/qpid.apache.org/electron/link.go | makeLocalLink | func makeLocalLink(sn *session, isSender bool, setting ...LinkOption) (linkSettings, error) {
l := linkSettings{
isSender: isSender,
capacity: 1,
prefetch: false,
session: sn,
}
for _, set := range setting {
set(&l)
}
if l.linkName == "" {
l.linkName = l.session.connection.container.nextLinkName()
}
... | go | func makeLocalLink(sn *session, isSender bool, setting ...LinkOption) (linkSettings, error) {
l := linkSettings{
isSender: isSender,
capacity: 1,
prefetch: false,
session: sn,
}
for _, set := range setting {
set(&l)
}
if l.linkName == "" {
l.linkName = l.session.connection.container.nextLinkName()
}
... | [
"func",
"makeLocalLink",
"(",
"sn",
"*",
"session",
",",
"isSender",
"bool",
",",
"setting",
"...",
"LinkOption",
")",
"(",
"linkSettings",
",",
"error",
")",
"{",
"l",
":=",
"linkSettings",
"{",
"isSender",
":",
"isSender",
",",
"capacity",
":",
"1",
",... | // Open a link and return the linkSettings. | [
"Open",
"a",
"link",
"and",
"return",
"the",
"linkSettings",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/link.go#L219-L262 |
22,429 | apache/qpid-proton | go/src/qpid.apache.org/electron/link.go | Credit | func (l *link) Credit() (credit int, err error) {
err = l.engine().InjectWait(func() error {
if l.Error() != nil {
return l.Error()
}
credit = l.pLink.Credit()
return nil
})
return
} | go | func (l *link) Credit() (credit int, err error) {
err = l.engine().InjectWait(func() error {
if l.Error() != nil {
return l.Error()
}
credit = l.pLink.Credit()
return nil
})
return
} | [
"func",
"(",
"l",
"*",
"link",
")",
"Credit",
"(",
")",
"(",
"credit",
"int",
",",
"err",
"error",
")",
"{",
"err",
"=",
"l",
".",
"engine",
"(",
")",
".",
"InjectWait",
"(",
"func",
"(",
")",
"error",
"{",
"if",
"l",
".",
"Error",
"(",
")",
... | // Not part of Link interface but use by Sender and Receiver. | [
"Not",
"part",
"of",
"Link",
"interface",
"but",
"use",
"by",
"Sender",
"and",
"Receiver",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/link.go#L287-L296 |
22,430 | apache/qpid-proton | go/genwrap.go | findEnums | func findEnums(header string) (enums []enumType) {
for _, enum := range enumDefRe.FindAllStringSubmatch(header, -1) {
enums = append(enums, enumType{enum[2], enumValRe.FindAllString(enum[1], -1)})
}
return enums
} | go | func findEnums(header string) (enums []enumType) {
for _, enum := range enumDefRe.FindAllStringSubmatch(header, -1) {
enums = append(enums, enumType{enum[2], enumValRe.FindAllString(enum[1], -1)})
}
return enums
} | [
"func",
"findEnums",
"(",
"header",
"string",
")",
"(",
"enums",
"[",
"]",
"enumType",
")",
"{",
"for",
"_",
",",
"enum",
":=",
"range",
"enumDefRe",
".",
"FindAllStringSubmatch",
"(",
"header",
",",
"-",
"1",
")",
"{",
"enums",
"=",
"append",
"(",
"... | // Find enums in a header file return map of enum name to values. | [
"Find",
"enums",
"in",
"a",
"header",
"file",
"return",
"map",
"of",
"enum",
"name",
"to",
"values",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/genwrap.go#L182-L187 |
22,431 | apache/qpid-proton | go/genwrap.go | event | func event(out io.Writer) {
event_h := readHeader("event")
// Event is implemented by hand in wrappers.go
// Get all the pn_event_type_t enum values
var etypes []eventType
enums := findEnums(event_h)
for _, e := range enums[0].Values {
if skipEventRe.FindStringSubmatch(e) == nil {
etypes = append(etypes, n... | go | func event(out io.Writer) {
event_h := readHeader("event")
// Event is implemented by hand in wrappers.go
// Get all the pn_event_type_t enum values
var etypes []eventType
enums := findEnums(event_h)
for _, e := range enums[0].Values {
if skipEventRe.FindStringSubmatch(e) == nil {
etypes = append(etypes, n... | [
"func",
"event",
"(",
"out",
"io",
".",
"Writer",
")",
"{",
"event_h",
":=",
"readHeader",
"(",
"\"",
"\"",
")",
"\n\n",
"// Event is implemented by hand in wrappers.go",
"// Get all the pn_event_type_t enum values",
"var",
"etypes",
"[",
"]",
"eventType",
"\n",
"en... | // Generate event wrappers. | [
"Generate",
"event",
"wrappers",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/genwrap.go#L272-L302 |
22,432 | apache/qpid-proton | go/genwrap.go | goFnName | func goFnName(api, fname string) string {
// Skip class, context and attachment functions.
if skipFnRe.FindStringSubmatch(api+"_"+fname) != nil {
return ""
}
return mixedCaseTrim(fname, "get_")
} | go | func goFnName(api, fname string) string {
// Skip class, context and attachment functions.
if skipFnRe.FindStringSubmatch(api+"_"+fname) != nil {
return ""
}
return mixedCaseTrim(fname, "get_")
} | [
"func",
"goFnName",
"(",
"api",
",",
"fname",
"string",
")",
"string",
"{",
"// Skip class, context and attachment functions.",
"if",
"skipFnRe",
".",
"FindStringSubmatch",
"(",
"api",
"+",
"\"",
"\"",
"+",
"fname",
")",
"!=",
"nil",
"{",
"return",
"\"",
"\"",... | // Return the go name of the function or "" to skip the function. | [
"Return",
"the",
"go",
"name",
"of",
"the",
"function",
"or",
"to",
"skip",
"the",
"function",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/genwrap.go#L468-L474 |
22,433 | apache/qpid-proton | go/examples/proton/broker.go | run | func (b *broker) run() error {
listener, err := net.Listen("tcp", *addr)
if err != nil {
return err
}
defer listener.Close()
fmt.Printf("Listening on %s\n", listener.Addr())
for {
conn, err := listener.Accept()
if err != nil {
debugf("Accept error: %v", err)
continue
}
adapter := proton.NewMessagi... | go | func (b *broker) run() error {
listener, err := net.Listen("tcp", *addr)
if err != nil {
return err
}
defer listener.Close()
fmt.Printf("Listening on %s\n", listener.Addr())
for {
conn, err := listener.Accept()
if err != nil {
debugf("Accept error: %v", err)
continue
}
adapter := proton.NewMessagi... | [
"func",
"(",
"b",
"*",
"broker",
")",
"run",
"(",
")",
"error",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"*",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"... | // Listens for connections and starts a proton.Engine for each one. | [
"Listens",
"for",
"connections",
"and",
"starts",
"a",
"proton",
".",
"Engine",
"for",
"each",
"one",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/proton/broker.go#L76-L106 |
22,434 | apache/qpid-proton | go/examples/proton/broker.go | HandleMessagingEvent | func (h *handler) HandleMessagingEvent(t proton.MessagingEvent, e proton.Event) {
switch t {
case proton.MStart:
h.injecter = e.Injecter()
case proton.MLinkOpening:
if e.Link().IsReceiver() {
h.startReceiver(e)
} else {
h.startSender(e)
}
case proton.MLinkClosed:
h.linkClosed(e.Link(), e.Link().R... | go | func (h *handler) HandleMessagingEvent(t proton.MessagingEvent, e proton.Event) {
switch t {
case proton.MStart:
h.injecter = e.Injecter()
case proton.MLinkOpening:
if e.Link().IsReceiver() {
h.startReceiver(e)
} else {
h.startSender(e)
}
case proton.MLinkClosed:
h.linkClosed(e.Link(), e.Link().R... | [
"func",
"(",
"h",
"*",
"handler",
")",
"HandleMessagingEvent",
"(",
"t",
"proton",
".",
"MessagingEvent",
",",
"e",
"proton",
".",
"Event",
")",
"{",
"switch",
"t",
"{",
"case",
"proton",
".",
"MStart",
":",
"h",
".",
"injecter",
"=",
"e",
".",
"Inje... | // HandleMessagingEvent handles an event, called in the handler goroutine. | [
"HandleMessagingEvent",
"handles",
"an",
"event",
"called",
"in",
"the",
"handler",
"goroutine",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/proton/broker.go#L128-L174 |
22,435 | apache/qpid-proton | go/examples/proton/broker.go | linkClosed | func (h *handler) linkClosed(l proton.Link, err error) {
if s, ok := h.senders[l]; ok {
s.stop()
delete(h.senders, l)
} else if r, ok := h.receivers[l]; ok {
r.stop()
delete(h.receivers, l)
}
} | go | func (h *handler) linkClosed(l proton.Link, err error) {
if s, ok := h.senders[l]; ok {
s.stop()
delete(h.senders, l)
} else if r, ok := h.receivers[l]; ok {
r.stop()
delete(h.receivers, l)
}
} | [
"func",
"(",
"h",
"*",
"handler",
")",
"linkClosed",
"(",
"l",
"proton",
".",
"Link",
",",
"err",
"error",
")",
"{",
"if",
"s",
",",
"ok",
":=",
"h",
".",
"senders",
"[",
"l",
"]",
";",
"ok",
"{",
"s",
".",
"stop",
"(",
")",
"\n",
"delete",
... | // linkClosed is called when a link has been closed by both ends.
// It removes the link from the handlers maps and stops its goroutine. | [
"linkClosed",
"is",
"called",
"when",
"a",
"link",
"has",
"been",
"closed",
"by",
"both",
"ends",
".",
"It",
"removes",
"the",
"link",
"from",
"the",
"handlers",
"maps",
"and",
"stops",
"its",
"goroutine",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/proton/broker.go#L178-L186 |
22,436 | apache/qpid-proton | go/examples/proton/broker.go | run | func (r *receiver) run() {
for rm := range r.buffer {
r.q <- rm.message
d := rm.delivery
// We are not in the handler goroutine so we Inject the accept function as a closure.
r.h.injecter.Inject(func() {
// Check that the receiver is still open, it may have been closed by the remote end.
if r == r.h.rece... | go | func (r *receiver) run() {
for rm := range r.buffer {
r.q <- rm.message
d := rm.delivery
// We are not in the handler goroutine so we Inject the accept function as a closure.
r.h.injecter.Inject(func() {
// Check that the receiver is still open, it may have been closed by the remote end.
if r == r.h.rece... | [
"func",
"(",
"r",
"*",
"receiver",
")",
"run",
"(",
")",
"{",
"for",
"rm",
":=",
"range",
"r",
".",
"buffer",
"{",
"r",
".",
"q",
"<-",
"rm",
".",
"message",
"\n",
"d",
":=",
"rm",
".",
"delivery",
"\n",
"// We are not in the handler goroutine so we In... | // run runs in a separate goroutine. It moves messages from the buffer to the
// queue for a receiver link, and injects a handler function to acknowledge the
// message and send a credit. | [
"run",
"runs",
"in",
"a",
"separate",
"goroutine",
".",
"It",
"moves",
"messages",
"from",
"the",
"buffer",
"to",
"the",
"queue",
"for",
"a",
"receiver",
"link",
"and",
"injects",
"a",
"handler",
"function",
"to",
"acknowledge",
"the",
"message",
"and",
"s... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/proton/broker.go#L234-L247 |
22,437 | apache/qpid-proton | go/examples/proton/broker.go | run | func (s *sender) run() {
var q queue // q is nil initially as we have no credit.
for {
select {
case _, ok := <-s.credit:
if !ok { // sender closed
return
}
q = s.q // We have credit, enable selecting on the queue.
case m, ok := <-q: // q is only enabled when we have credit.
if !ok { // queue c... | go | func (s *sender) run() {
var q queue // q is nil initially as we have no credit.
for {
select {
case _, ok := <-s.credit:
if !ok { // sender closed
return
}
q = s.q // We have credit, enable selecting on the queue.
case m, ok := <-q: // q is only enabled when we have credit.
if !ok { // queue c... | [
"func",
"(",
"s",
"*",
"sender",
")",
"run",
"(",
")",
"{",
"var",
"q",
"queue",
"// q is nil initially as we have no credit.",
"\n",
"for",
"{",
"select",
"{",
"case",
"_",
",",
"ok",
":=",
"<-",
"s",
".",
"credit",
":",
"if",
"!",
"ok",
"{",
"// se... | // run runs in a separate goroutine. It monitors the queue for messages and injects
// a function to send them when there is credit | [
"run",
"runs",
"in",
"a",
"separate",
"goroutine",
".",
"It",
"monitors",
"the",
"queue",
"for",
"messages",
"and",
"injects",
"a",
"function",
"to",
"send",
"them",
"when",
"there",
"is",
"credit"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/proton/broker.go#L287-L324 |
22,438 | apache/qpid-proton | go/examples/proton/broker.go | sendOne | func (s *sender) sendOne(m amqp.Message) error {
delivery, err := s.l.Send(m)
if err == nil {
delivery.Settle() // Pre-settled, unreliable.
debugf("link %s sent %#v", s.l, m)
} else {
s.q.PutBack(m) // Put the message back on the queue, don't block
}
return err
} | go | func (s *sender) sendOne(m amqp.Message) error {
delivery, err := s.l.Send(m)
if err == nil {
delivery.Settle() // Pre-settled, unreliable.
debugf("link %s sent %#v", s.l, m)
} else {
s.q.PutBack(m) // Put the message back on the queue, don't block
}
return err
} | [
"func",
"(",
"s",
"*",
"sender",
")",
"sendOne",
"(",
"m",
"amqp",
".",
"Message",
")",
"error",
"{",
"delivery",
",",
"err",
":=",
"s",
".",
"l",
".",
"Send",
"(",
"m",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"delivery",
".",
"Settle",
"(",
... | // sendOne runs in the handler goroutine. It sends a single message. | [
"sendOne",
"runs",
"in",
"the",
"handler",
"goroutine",
".",
"It",
"sends",
"a",
"single",
"message",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/examples/proton/broker.go#L327-L336 |
22,439 | apache/qpid-proton | go/src/qpid.apache.org/proton/error.go | Set | func (e *ErrorHolder) Set(err error) {
if err != nil {
e.once.Do(func() { e.value.Store(err) })
}
} | go | func (e *ErrorHolder) Set(err error) {
if err != nil {
e.once.Do(func() { e.value.Store(err) })
}
} | [
"func",
"(",
"e",
"*",
"ErrorHolder",
")",
"Set",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"e",
".",
"once",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"e",
".",
"value",
".",
"Store",
"(",
"err",
")",
"}",
")",
"\n",
"}",
... | // Set the error if not already set | [
"Set",
"the",
"error",
"if",
"not",
"already",
"set"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/error.go#L75-L79 |
22,440 | apache/qpid-proton | go/src/qpid.apache.org/proton/error.go | Get | func (e *ErrorHolder) Get() (err error) {
err, _ = e.value.Load().(error)
return
} | go | func (e *ErrorHolder) Get() (err error) {
err, _ = e.value.Load().(error)
return
} | [
"func",
"(",
"e",
"*",
"ErrorHolder",
")",
"Get",
"(",
")",
"(",
"err",
"error",
")",
"{",
"err",
",",
"_",
"=",
"e",
".",
"value",
".",
"Load",
"(",
")",
".",
"(",
"error",
")",
"\n",
"return",
"\n",
"}"
] | // Get the error. | [
"Get",
"the",
"error",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/error.go#L82-L85 |
22,441 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | User | func User(user string) ConnectionOption {
return func(c *connection) {
c.user = user
c.pConnection.SetUser(user)
}
} | go | func User(user string) ConnectionOption {
return func(c *connection) {
c.user = user
c.pConnection.SetUser(user)
}
} | [
"func",
"User",
"(",
"user",
"string",
")",
"ConnectionOption",
"{",
"return",
"func",
"(",
"c",
"*",
"connection",
")",
"{",
"c",
".",
"user",
"=",
"user",
"\n",
"c",
".",
"pConnection",
".",
"SetUser",
"(",
"user",
")",
"\n",
"}",
"\n",
"}"
] | // User returns a ConnectionOption sets the user name for a connection | [
"User",
"returns",
"a",
"ConnectionOption",
"sets",
"the",
"user",
"name",
"for",
"a",
"connection"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L118-L123 |
22,442 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | VirtualHost | func VirtualHost(virtualHost string) ConnectionOption {
return func(c *connection) {
c.virtualHost = virtualHost
c.pConnection.SetHostname(virtualHost)
}
} | go | func VirtualHost(virtualHost string) ConnectionOption {
return func(c *connection) {
c.virtualHost = virtualHost
c.pConnection.SetHostname(virtualHost)
}
} | [
"func",
"VirtualHost",
"(",
"virtualHost",
"string",
")",
"ConnectionOption",
"{",
"return",
"func",
"(",
"c",
"*",
"connection",
")",
"{",
"c",
".",
"virtualHost",
"=",
"virtualHost",
"\n",
"c",
".",
"pConnection",
".",
"SetHostname",
"(",
"virtualHost",
")... | // VirtualHost returns a ConnectionOption to set the AMQP virtual host for the connection.
// Only applies to outbound client connection. | [
"VirtualHost",
"returns",
"a",
"ConnectionOption",
"to",
"set",
"the",
"AMQP",
"virtual",
"host",
"for",
"the",
"connection",
".",
"Only",
"applies",
"to",
"outbound",
"client",
"connection",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L127-L132 |
22,443 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | Password | func Password(password []byte) ConnectionOption {
return func(c *connection) { c.pConnection.SetPassword(password) }
} | go | func Password(password []byte) ConnectionOption {
return func(c *connection) { c.pConnection.SetPassword(password) }
} | [
"func",
"Password",
"(",
"password",
"[",
"]",
"byte",
")",
"ConnectionOption",
"{",
"return",
"func",
"(",
"c",
"*",
"connection",
")",
"{",
"c",
".",
"pConnection",
".",
"SetPassword",
"(",
"password",
")",
"}",
"\n",
"}"
] | // Password returns a ConnectionOption to set the password used to establish a
// connection. Only applies to outbound client connection.
//
// The connection will erase its copy of the password from memory as soon as it
// has been used to authenticate. If you are concerned about passwords staying in
// memory you sh... | [
"Password",
"returns",
"a",
"ConnectionOption",
"to",
"set",
"the",
"password",
"used",
"to",
"establish",
"a",
"connection",
".",
"Only",
"applies",
"to",
"outbound",
"client",
"connection",
".",
"The",
"connection",
"will",
"erase",
"its",
"copy",
"of",
"the... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L142-L144 |
22,444 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | Parent | func Parent(cont Container) ConnectionOption {
return func(c *connection) { c.container = cont.(*container) }
} | go | func Parent(cont Container) ConnectionOption {
return func(c *connection) { c.container = cont.(*container) }
} | [
"func",
"Parent",
"(",
"cont",
"Container",
")",
"ConnectionOption",
"{",
"return",
"func",
"(",
"c",
"*",
"connection",
")",
"{",
"c",
".",
"container",
"=",
"cont",
".",
"(",
"*",
"container",
")",
"}",
"\n",
"}"
] | // Parent returns a ConnectionOption that associates the Connection with it's Container
// If not set a connection will create its own default container. | [
"Parent",
"returns",
"a",
"ConnectionOption",
"that",
"associates",
"the",
"Connection",
"with",
"it",
"s",
"Container",
"If",
"not",
"set",
"a",
"connection",
"will",
"create",
"its",
"own",
"default",
"container",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L164-L166 |
22,445 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | ContainerId | func ContainerId(id string) ConnectionOption {
return func(c *connection) { c.container = NewContainer(id).(*container) }
} | go | func ContainerId(id string) ConnectionOption {
return func(c *connection) { c.container = NewContainer(id).(*container) }
} | [
"func",
"ContainerId",
"(",
"id",
"string",
")",
"ConnectionOption",
"{",
"return",
"func",
"(",
"c",
"*",
"connection",
")",
"{",
"c",
".",
"container",
"=",
"NewContainer",
"(",
"id",
")",
".",
"(",
"*",
"container",
")",
"}",
"\n",
"}"
] | // ContainerId returns a ConnectionOption that creates a new Container
// with id and associates it with the connection | [
"ContainerId",
"returns",
"a",
"ConnectionOption",
"that",
"creates",
"a",
"new",
"Container",
"with",
"id",
"and",
"associates",
"it",
"with",
"the",
"connection"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L170-L172 |
22,446 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | NewConnection | func NewConnection(conn net.Conn, opts ...ConnectionOption) (*connection, error) {
c := &connection{
conn: conn,
}
c.handler = newHandler(c)
var err error
c.engine, err = proton.NewEngine(c.conn, c.handler.delegator)
if err != nil {
return nil, err
}
c.pConnection = c.engine.Connection()
for _, opt := rang... | go | func NewConnection(conn net.Conn, opts ...ConnectionOption) (*connection, error) {
c := &connection{
conn: conn,
}
c.handler = newHandler(c)
var err error
c.engine, err = proton.NewEngine(c.conn, c.handler.delegator)
if err != nil {
return nil, err
}
c.pConnection = c.engine.Connection()
for _, opt := rang... | [
"func",
"NewConnection",
"(",
"conn",
"net",
".",
"Conn",
",",
"opts",
"...",
"ConnectionOption",
")",
"(",
"*",
"connection",
",",
"error",
")",
"{",
"c",
":=",
"&",
"connection",
"{",
"conn",
":",
"conn",
",",
"}",
"\n",
"c",
".",
"handler",
"=",
... | // NewConnection creates a connection with the given options.
// Options are applied in order. | [
"NewConnection",
"creates",
"a",
"connection",
"with",
"the",
"given",
"options",
".",
"Options",
"are",
"applied",
"in",
"order",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L194-L226 |
22,447 | apache/qpid-proton | go/src/qpid.apache.org/electron/connection.go | SASLAllowInsecure | func SASLAllowInsecure(b bool) ConnectionOption {
return func(c *connection) { sasl(c).SetAllowInsecureMechs(b) }
} | go | func SASLAllowInsecure(b bool) ConnectionOption {
return func(c *connection) { sasl(c).SetAllowInsecureMechs(b) }
} | [
"func",
"SASLAllowInsecure",
"(",
"b",
"bool",
")",
"ConnectionOption",
"{",
"return",
"func",
"(",
"c",
"*",
"connection",
")",
"{",
"sasl",
"(",
"c",
")",
".",
"SetAllowInsecureMechs",
"(",
"b",
")",
"}",
"\n",
"}"
] | // SASLAllowInsecure returns a ConnectionOption that allows or disallows clear
// text SASL authentication mechanisms
//
// By default the SASL layer is configured not to allow mechanisms that disclose
// the clear text of the password over an unencrypted AMQP connection. This specifically
// will disallow the use of t... | [
"SASLAllowInsecure",
"returns",
"a",
"ConnectionOption",
"that",
"allows",
"or",
"disallows",
"clear",
"text",
"SASL",
"authentication",
"mechanisms",
"By",
"default",
"the",
"SASL",
"layer",
"is",
"configured",
"not",
"to",
"allow",
"mechanisms",
"that",
"disclose"... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/connection.go#L394-L396 |
22,448 | apache/qpid-proton | go/src/qpid.apache.org/amqp/marshal.go | MarshalUnsafe | func MarshalUnsafe(v interface{}, pnData unsafe.Pointer) (err error) {
return recoverMarshal(v, (*C.pn_data_t)(pnData))
} | go | func MarshalUnsafe(v interface{}, pnData unsafe.Pointer) (err error) {
return recoverMarshal(v, (*C.pn_data_t)(pnData))
} | [
"func",
"MarshalUnsafe",
"(",
"v",
"interface",
"{",
"}",
",",
"pnData",
"unsafe",
".",
"Pointer",
")",
"(",
"err",
"error",
")",
"{",
"return",
"recoverMarshal",
"(",
"v",
",",
"(",
"*",
"C",
".",
"pn_data_t",
")",
"(",
"pnData",
")",
")",
"\n",
"... | // Internal use only | [
"Internal",
"use",
"only"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/marshal.go#L128-L130 |
22,449 | apache/qpid-proton | go/src/qpid.apache.org/amqp/marshal.go | NewEncoder | func NewEncoder(w io.Writer) *Encoder {
return &Encoder{w, make([]byte, minEncode)}
} | go | func NewEncoder(w io.Writer) *Encoder {
return &Encoder{w, make([]byte, minEncode)}
} | [
"func",
"NewEncoder",
"(",
"w",
"io",
".",
"Writer",
")",
"*",
"Encoder",
"{",
"return",
"&",
"Encoder",
"{",
"w",
",",
"make",
"(",
"[",
"]",
"byte",
",",
"minEncode",
")",
"}",
"\n",
"}"
] | // New encoder returns a new encoder that writes to w. | [
"New",
"encoder",
"returns",
"a",
"new",
"encoder",
"that",
"writes",
"to",
"w",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/marshal.go#L349-L351 |
22,450 | apache/qpid-proton | go/src/qpid.apache.org/electron/container.go | NewContainer | func NewContainer(id string) Container {
if id == "" {
id = proton.UUID4().String()
}
cont := &container{id: id}
return cont
} | go | func NewContainer(id string) Container {
if id == "" {
id = proton.UUID4().String()
}
cont := &container{id: id}
return cont
} | [
"func",
"NewContainer",
"(",
"id",
"string",
")",
"Container",
"{",
"if",
"id",
"==",
"\"",
"\"",
"{",
"id",
"=",
"proton",
".",
"UUID4",
"(",
")",
".",
"String",
"(",
")",
"\n",
"}",
"\n",
"cont",
":=",
"&",
"container",
"{",
"id",
":",
"id",
... | // NewContainer creates a new container. The id must be unique in your
// distributed application, all connections created by the container
// will have this container-id.
//
// If id == "" a random UUID will be generated for the id. | [
"NewContainer",
"creates",
"a",
"new",
"container",
".",
"The",
"id",
"must",
"be",
"unique",
"in",
"your",
"distributed",
"application",
"all",
"connections",
"created",
"by",
"the",
"container",
"will",
"have",
"this",
"container",
"-",
"id",
".",
"If",
"i... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/container.go#L72-L78 |
22,451 | apache/qpid-proton | go/src/qpid.apache.org/proton/engine.go | Close | func (eng *Engine) Close(err error) {
_ = eng.Inject(func() { CloseError(eng.Connection(), err) })
<-eng.running
} | go | func (eng *Engine) Close(err error) {
_ = eng.Inject(func() { CloseError(eng.Connection(), err) })
<-eng.running
} | [
"func",
"(",
"eng",
"*",
"Engine",
")",
"Close",
"(",
"err",
"error",
")",
"{",
"_",
"=",
"eng",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"CloseError",
"(",
"eng",
".",
"Connection",
"(",
")",
",",
"err",
")",
"}",
")",
"\n",
"<-",
"eng",
"... | // Close the engine's connection.
// If err != nil pass it to the remote end as the close condition.
// Returns when the remote end closes or disconnects. | [
"Close",
"the",
"engine",
"s",
"connection",
".",
"If",
"err",
"!",
"=",
"nil",
"pass",
"it",
"to",
"the",
"remote",
"end",
"as",
"the",
"close",
"condition",
".",
"Returns",
"when",
"the",
"remote",
"end",
"closes",
"or",
"disconnects",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/engine.go#L237-L240 |
22,452 | apache/qpid-proton | go/src/qpid.apache.org/proton/engine.go | CloseTimeout | func (eng *Engine) CloseTimeout(err error, timeout time.Duration) {
_ = eng.Inject(func() { CloseError(eng.Connection(), err) })
select {
case <-eng.running:
case <-time.After(timeout):
eng.Disconnect(err)
}
} | go | func (eng *Engine) CloseTimeout(err error, timeout time.Duration) {
_ = eng.Inject(func() { CloseError(eng.Connection(), err) })
select {
case <-eng.running:
case <-time.After(timeout):
eng.Disconnect(err)
}
} | [
"func",
"(",
"eng",
"*",
"Engine",
")",
"CloseTimeout",
"(",
"err",
"error",
",",
"timeout",
"time",
".",
"Duration",
")",
"{",
"_",
"=",
"eng",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"CloseError",
"(",
"eng",
".",
"Connection",
"(",
")",
",",
... | // CloseTimeout like Close but disconnect if the remote end doesn't close within timeout. | [
"CloseTimeout",
"like",
"Close",
"but",
"disconnect",
"if",
"the",
"remote",
"end",
"doesn",
"t",
"close",
"within",
"timeout",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/engine.go#L243-L250 |
22,453 | apache/qpid-proton | go/src/qpid.apache.org/proton/engine.go | Disconnect | func (eng *Engine) Disconnect(err error) {
_ = eng.Inject(func() { eng.disconnect(err) })
<-eng.running
} | go | func (eng *Engine) Disconnect(err error) {
_ = eng.Inject(func() { eng.disconnect(err) })
<-eng.running
} | [
"func",
"(",
"eng",
"*",
"Engine",
")",
"Disconnect",
"(",
"err",
"error",
")",
"{",
"_",
"=",
"eng",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"eng",
".",
"disconnect",
"(",
"err",
")",
"}",
")",
"\n",
"<-",
"eng",
".",
"running",
"\n",
"}"
] | // Disconnect the engine's connection immediately without an AMQP close.
// Process any termination events before returning. | [
"Disconnect",
"the",
"engine",
"s",
"connection",
"immediately",
"without",
"an",
"AMQP",
"close",
".",
"Process",
"any",
"termination",
"events",
"before",
"returning",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/engine.go#L254-L257 |
22,454 | apache/qpid-proton | go/src/qpid.apache.org/proton/engine.go | tick | func (eng *Engine) tick() {
// Proton wants millisecond monotonic time
now := int64(elapsed() / time.Millisecond)
next := eng.Transport().Tick(now)
if next != 0 {
eng.timer.Reset(time.Duration((next - now) * int64(time.Millisecond)))
}
} | go | func (eng *Engine) tick() {
// Proton wants millisecond monotonic time
now := int64(elapsed() / time.Millisecond)
next := eng.Transport().Tick(now)
if next != 0 {
eng.timer.Reset(time.Duration((next - now) * int64(time.Millisecond)))
}
} | [
"func",
"(",
"eng",
"*",
"Engine",
")",
"tick",
"(",
")",
"{",
"// Proton wants millisecond monotonic time",
"now",
":=",
"int64",
"(",
"elapsed",
"(",
")",
"/",
"time",
".",
"Millisecond",
")",
"\n",
"next",
":=",
"eng",
".",
"Transport",
"(",
")",
".",... | // Let proton run timed activity and set up the next tick | [
"Let",
"proton",
"run",
"timed",
"activity",
"and",
"set",
"up",
"the",
"next",
"tick"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/engine.go#L274-L281 |
22,455 | apache/qpid-proton | go/src/qpid.apache.org/amqp/unmarshal.go | Decode | func (d *Decoder) Decode(v interface{}) (err error) {
data := C.pn_data(0)
defer C.pn_data_free(data)
var n int
for n, err = decode(data, d.buffer.Bytes()); err == EndOfData; {
err = d.more()
if err == nil {
n, err = decode(data, d.buffer.Bytes())
}
}
if err == nil {
if err = recoverUnmarshal(v, data);... | go | func (d *Decoder) Decode(v interface{}) (err error) {
data := C.pn_data(0)
defer C.pn_data_free(data)
var n int
for n, err = decode(data, d.buffer.Bytes()); err == EndOfData; {
err = d.more()
if err == nil {
n, err = decode(data, d.buffer.Bytes())
}
}
if err == nil {
if err = recoverUnmarshal(v, data);... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"data",
":=",
"C",
".",
"pn_data",
"(",
"0",
")",
"\n",
"defer",
"C",
".",
"pn_data_free",
"(",
"data",
")",
"\n",
"var",
"n",... | // Decode reads the next AMQP value from the Reader and stores it in the value pointed to by v.
//
// See the documentation for Unmarshal for details about the conversion of AMQP into a Go value.
// | [
"Decode",
"reads",
"the",
"next",
"AMQP",
"value",
"from",
"the",
"Reader",
"and",
"stores",
"it",
"in",
"the",
"value",
"pointed",
"to",
"by",
"v",
".",
"See",
"the",
"documentation",
"for",
"Unmarshal",
"for",
"details",
"about",
"the",
"conversion",
"of... | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/unmarshal.go#L130-L146 |
22,456 | apache/qpid-proton | go/src/qpid.apache.org/amqp/unmarshal.go | more | func (d *Decoder) more() error {
var readSize int64 = minDecode
if int64(d.buffer.Len()) > readSize { // Grow by doubling
readSize = int64(d.buffer.Len())
}
var n int64
n, err := d.buffer.ReadFrom(io.LimitReader(d.reader, readSize))
if n == 0 && err == nil { // ReadFrom won't report io.EOF, just returns 0
err... | go | func (d *Decoder) more() error {
var readSize int64 = minDecode
if int64(d.buffer.Len()) > readSize { // Grow by doubling
readSize = int64(d.buffer.Len())
}
var n int64
n, err := d.buffer.ReadFrom(io.LimitReader(d.reader, readSize))
if n == 0 && err == nil { // ReadFrom won't report io.EOF, just returns 0
err... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"more",
"(",
")",
"error",
"{",
"var",
"readSize",
"int64",
"=",
"minDecode",
"\n",
"if",
"int64",
"(",
"d",
".",
"buffer",
".",
"Len",
"(",
")",
")",
">",
"readSize",
"{",
"// Grow by doubling",
"readSize",
"="... | // more reads more data when we can't parse a complete AMQP type | [
"more",
"reads",
"more",
"data",
"when",
"we",
"can",
"t",
"parse",
"a",
"complete",
"AMQP",
"type"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/unmarshal.go#L261-L272 |
22,457 | apache/qpid-proton | go/src/qpid.apache.org/amqp/unmarshal.go | getMap | func getMap(data *C.pn_data_t, v interface{}) {
panicUnless(C.pn_data_type(data) == C.PN_MAP, data, v)
n := int(C.pn_data_get_map(data)) / 2
mapValue := reflect.ValueOf(v).Elem()
mapValue.Set(reflect.MakeMap(mapValue.Type())) // Clear the map
data.enter(v)
defer data.exit(v)
// Allocate re-usable key/val values
... | go | func getMap(data *C.pn_data_t, v interface{}) {
panicUnless(C.pn_data_type(data) == C.PN_MAP, data, v)
n := int(C.pn_data_get_map(data)) / 2
mapValue := reflect.ValueOf(v).Elem()
mapValue.Set(reflect.MakeMap(mapValue.Type())) // Clear the map
data.enter(v)
defer data.exit(v)
// Allocate re-usable key/val values
... | [
"func",
"getMap",
"(",
"data",
"*",
"C",
".",
"pn_data_t",
",",
"v",
"interface",
"{",
"}",
")",
"{",
"panicUnless",
"(",
"C",
".",
"pn_data_type",
"(",
"data",
")",
"==",
"C",
".",
"PN_MAP",
",",
"data",
",",
"v",
")",
"\n",
"n",
":=",
"int",
... | // get into map pointed at by v | [
"get",
"into",
"map",
"pointed",
"at",
"by",
"v"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/unmarshal.go#L652-L673 |
22,458 | apache/qpid-proton | go/src/qpid.apache.org/amqp/unmarshal.go | decode | func decode(data *C.pn_data_t, bytes []byte) (int, error) {
n := C.pn_data_decode(data, cPtr(bytes), cLen(bytes))
if n == C.PN_UNDERFLOW {
C.pn_error_clear(C.pn_data_error(data))
return 0, EndOfData
} else if n <= 0 {
return 0, &UnmarshalError{s: fmt.Sprintf("unmarshal %v", PnErrorCode(n))}
}
return int(n), ... | go | func decode(data *C.pn_data_t, bytes []byte) (int, error) {
n := C.pn_data_decode(data, cPtr(bytes), cLen(bytes))
if n == C.PN_UNDERFLOW {
C.pn_error_clear(C.pn_data_error(data))
return 0, EndOfData
} else if n <= 0 {
return 0, &UnmarshalError{s: fmt.Sprintf("unmarshal %v", PnErrorCode(n))}
}
return int(n), ... | [
"func",
"decode",
"(",
"data",
"*",
"C",
".",
"pn_data_t",
",",
"bytes",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
":=",
"C",
".",
"pn_data_decode",
"(",
"data",
",",
"cPtr",
"(",
"bytes",
")",
",",
"cLen",
"(",
"bytes",
"... | // decode from bytes.
// Return bytes decoded or 0 if we could not decode a complete object.
// | [
"decode",
"from",
"bytes",
".",
"Return",
"bytes",
"decoded",
"or",
"0",
"if",
"we",
"could",
"not",
"decode",
"a",
"complete",
"object",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/amqp/unmarshal.go#L716-L725 |
22,459 | apache/qpid-proton | go/src/qpid.apache.org/electron/sender.go | String | func (s SentStatus) String() string {
switch s {
case Unsent:
return "unsent"
case Unacknowledged:
return "unacknowledged"
case Accepted:
return "accepted"
case Rejected:
return "rejected"
case Released:
return "released"
case Unknown:
return "unknown"
default:
return fmt.Sprintf("invalid(%d)", s)... | go | func (s SentStatus) String() string {
switch s {
case Unsent:
return "unsent"
case Unacknowledged:
return "unacknowledged"
case Accepted:
return "accepted"
case Rejected:
return "rejected"
case Released:
return "released"
case Unknown:
return "unknown"
default:
return fmt.Sprintf("invalid(%d)", s)... | [
"func",
"(",
"s",
"SentStatus",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"s",
"{",
"case",
"Unsent",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Unacknowledged",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Accepted",
":",
"return",
"\"",
"\"",
"... | // String human readable name for SentStatus. | [
"String",
"human",
"readable",
"name",
"for",
"SentStatus",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/sender.go#L119-L136 |
22,460 | apache/qpid-proton | go/src/qpid.apache.org/electron/sender.go | sentStatus | func sentStatus(d uint64) SentStatus {
switch d {
case proton.Accepted:
return Accepted
case proton.Rejected:
return Rejected
case proton.Released, proton.Modified:
return Released
default:
return Unknown
}
} | go | func sentStatus(d uint64) SentStatus {
switch d {
case proton.Accepted:
return Accepted
case proton.Rejected:
return Rejected
case proton.Released, proton.Modified:
return Released
default:
return Unknown
}
} | [
"func",
"sentStatus",
"(",
"d",
"uint64",
")",
"SentStatus",
"{",
"switch",
"d",
"{",
"case",
"proton",
".",
"Accepted",
":",
"return",
"Accepted",
"\n",
"case",
"proton",
".",
"Rejected",
":",
"return",
"Rejected",
"\n",
"case",
"proton",
".",
"Released",... | // Convert proton delivery state code to SentStatus value | [
"Convert",
"proton",
"delivery",
"state",
"code",
"to",
"SentStatus",
"value"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/sender.go#L139-L150 |
22,461 | apache/qpid-proton | go/src/qpid.apache.org/electron/sender.go | send | func (s *sender) send(sm *sendable) {
if err := s.Error(); err != nil {
sm.unsent(err)
return
}
bytes, err := s.session.connection.mc.Encode(sm.m, nil)
close(sm.sent) // Safe to re-use sm.m now
if err != nil {
sm.unsent(err)
return
}
d, err := s.pLink.SendMessageBytes(bytes)
if err != nil {
sm.unsent(... | go | func (s *sender) send(sm *sendable) {
if err := s.Error(); err != nil {
sm.unsent(err)
return
}
bytes, err := s.session.connection.mc.Encode(sm.m, nil)
close(sm.sent) // Safe to re-use sm.m now
if err != nil {
sm.unsent(err)
return
}
d, err := s.pLink.SendMessageBytes(bytes)
if err != nil {
sm.unsent(... | [
"func",
"(",
"s",
"*",
"sender",
")",
"send",
"(",
"sm",
"*",
"sendable",
")",
"{",
"if",
"err",
":=",
"s",
".",
"Error",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"sm",
".",
"unsent",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"bytes",
... | // Called in handler goroutine with credit > 0 | [
"Called",
"in",
"handler",
"goroutine",
"with",
"credit",
">",
"0"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/sender.go#L192-L215 |
22,462 | apache/qpid-proton | go/src/qpid.apache.org/electron/sender.go | Accept | func (in *IncomingSender) Accept() Endpoint {
return in.accept(func() Endpoint { return newSender(in.linkSettings) })
} | go | func (in *IncomingSender) Accept() Endpoint {
return in.accept(func() Endpoint { return newSender(in.linkSettings) })
} | [
"func",
"(",
"in",
"*",
"IncomingSender",
")",
"Accept",
"(",
")",
"Endpoint",
"{",
"return",
"in",
".",
"accept",
"(",
"func",
"(",
")",
"Endpoint",
"{",
"return",
"newSender",
"(",
"in",
".",
"linkSettings",
")",
"}",
")",
"\n",
"}"
] | // Accept accepts an incoming sender endpoint | [
"Accept",
"accepts",
"an",
"incoming",
"sender",
"endpoint"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/sender.go#L305-L307 |
22,463 | apache/qpid-proton | go/src/qpid.apache.org/electron/sender.go | valid | func (s *sender) valid() bool {
s2, ok := s.handler().links[s.pLink].(*sender)
return ok && s2 == s
} | go | func (s *sender) valid() bool {
s2, ok := s.handler().links[s.pLink].(*sender)
return ok && s2 == s
} | [
"func",
"(",
"s",
"*",
"sender",
")",
"valid",
"(",
")",
"bool",
"{",
"s2",
",",
"ok",
":=",
"s",
".",
"handler",
"(",
")",
".",
"links",
"[",
"s",
".",
"pLink",
"]",
".",
"(",
"*",
"sender",
")",
"\n",
"return",
"ok",
"&&",
"s2",
"==",
"s"... | // Call in injected functions to check if the sender is valid. | [
"Call",
"in",
"injected",
"functions",
"to",
"check",
"if",
"the",
"sender",
"is",
"valid",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/sender.go#L310-L313 |
22,464 | jmhodges/levigo | db.go | RepairDatabase | func RepairDatabase(dbname string, o *Options) error {
var errStr *C.char
ldbname := C.CString(dbname)
defer C.free(unsafe.Pointer(ldbname))
C.leveldb_repair_db(o.Opt, ldbname, &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C.leveldb_free(unsafe.Pointer(errStr))
return DatabaseError(gs)
}
return nil... | go | func RepairDatabase(dbname string, o *Options) error {
var errStr *C.char
ldbname := C.CString(dbname)
defer C.free(unsafe.Pointer(ldbname))
C.leveldb_repair_db(o.Opt, ldbname, &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C.leveldb_free(unsafe.Pointer(errStr))
return DatabaseError(gs)
}
return nil... | [
"func",
"RepairDatabase",
"(",
"dbname",
"string",
",",
"o",
"*",
"Options",
")",
"error",
"{",
"var",
"errStr",
"*",
"C",
".",
"char",
"\n",
"ldbname",
":=",
"C",
".",
"CString",
"(",
"dbname",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
... | // RepairDatabase attempts to repair a database.
//
// If the database is unrepairable, an error is returned. | [
"RepairDatabase",
"attempts",
"to",
"repair",
"a",
"database",
".",
"If",
"the",
"database",
"is",
"unrepairable",
"an",
"error",
"is",
"returned",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/db.go#L128-L140 |
22,465 | jmhodges/levigo | db.go | Delete | func (db *DB) Delete(wo *WriteOptions, key []byte) error {
if db.closed {
panic(ErrDBClosed)
}
var errStr *C.char
var k *C.char
if len(key) != 0 {
k = (*C.char)(unsafe.Pointer(&key[0]))
}
C.leveldb_delete(
db.Ldb, wo.Opt, k, C.size_t(len(key)), &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C... | go | func (db *DB) Delete(wo *WriteOptions, key []byte) error {
if db.closed {
panic(ErrDBClosed)
}
var errStr *C.char
var k *C.char
if len(key) != 0 {
k = (*C.char)(unsafe.Pointer(&key[0]))
}
C.leveldb_delete(
db.Ldb, wo.Opt, k, C.size_t(len(key)), &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C... | [
"func",
"(",
"db",
"*",
"DB",
")",
"Delete",
"(",
"wo",
"*",
"WriteOptions",
",",
"key",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"db",
".",
"closed",
"{",
"panic",
"(",
"ErrDBClosed",
")",
"\n",
"}",
"\n\n",
"var",
"errStr",
"*",
"C",
".",
"... | // Delete removes the data associated with the key from the database.
//
// The key byte slice may be reused safely. Delete takes a copy of
// them before returning. The WriteOptions passed in can be reused by
// multiple calls to this and if the WriteOptions is left unchanged. | [
"Delete",
"removes",
"the",
"data",
"associated",
"with",
"the",
"key",
"from",
"the",
"database",
".",
"The",
"key",
"byte",
"slice",
"may",
"be",
"reused",
"safely",
".",
"Delete",
"takes",
"a",
"copy",
"of",
"them",
"before",
"returning",
".",
"The",
... | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/db.go#L222-L242 |
22,466 | jmhodges/levigo | db.go | Write | func (db *DB) Write(wo *WriteOptions, w *WriteBatch) error {
if db.closed {
panic(ErrDBClosed)
}
var errStr *C.char
C.leveldb_write(db.Ldb, wo.Opt, w.wbatch, &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C.leveldb_free(unsafe.Pointer(errStr))
return DatabaseError(gs)
}
return nil
} | go | func (db *DB) Write(wo *WriteOptions, w *WriteBatch) error {
if db.closed {
panic(ErrDBClosed)
}
var errStr *C.char
C.leveldb_write(db.Ldb, wo.Opt, w.wbatch, &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C.leveldb_free(unsafe.Pointer(errStr))
return DatabaseError(gs)
}
return nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"Write",
"(",
"wo",
"*",
"WriteOptions",
",",
"w",
"*",
"WriteBatch",
")",
"error",
"{",
"if",
"db",
".",
"closed",
"{",
"panic",
"(",
"ErrDBClosed",
")",
"\n",
"}",
"\n\n",
"var",
"errStr",
"*",
"C",
".",
"char... | // Write atomically writes a WriteBatch to disk. The WriteOptions
// passed in can be reused by multiple calls to this and other methods. | [
"Write",
"atomically",
"writes",
"a",
"WriteBatch",
"to",
"disk",
".",
"The",
"WriteOptions",
"passed",
"in",
"can",
"be",
"reused",
"by",
"multiple",
"calls",
"to",
"this",
"and",
"other",
"methods",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/db.go#L246-L259 |
22,467 | jmhodges/levigo | db.go | PropertyValue | func (db *DB) PropertyValue(propName string) string {
if db.closed {
panic(ErrDBClosed)
}
cname := C.CString(propName)
value := C.GoString(C.leveldb_property_value(db.Ldb, cname))
C.free(unsafe.Pointer(cname))
return value
} | go | func (db *DB) PropertyValue(propName string) string {
if db.closed {
panic(ErrDBClosed)
}
cname := C.CString(propName)
value := C.GoString(C.leveldb_property_value(db.Ldb, cname))
C.free(unsafe.Pointer(cname))
return value
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"PropertyValue",
"(",
"propName",
"string",
")",
"string",
"{",
"if",
"db",
".",
"closed",
"{",
"panic",
"(",
"ErrDBClosed",
")",
"\n",
"}",
"\n\n",
"cname",
":=",
"C",
".",
"CString",
"(",
"propName",
")",
"\n",
... | // PropertyValue returns the value of a database property.
//
// Examples of properties include "leveldb.stats", "leveldb.sstables",
// and "leveldb.num-files-at-level0". | [
"PropertyValue",
"returns",
"the",
"value",
"of",
"a",
"database",
"property",
".",
"Examples",
"of",
"properties",
"include",
"leveldb",
".",
"stats",
"leveldb",
".",
"sstables",
"and",
"leveldb",
".",
"num",
"-",
"files",
"-",
"at",
"-",
"level0",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/db.go#L320-L329 |
22,468 | jmhodges/levigo | db.go | NewSnapshot | func (db *DB) NewSnapshot() *Snapshot {
if db.closed {
panic(ErrDBClosed)
}
return &Snapshot{C.leveldb_create_snapshot(db.Ldb)}
} | go | func (db *DB) NewSnapshot() *Snapshot {
if db.closed {
panic(ErrDBClosed)
}
return &Snapshot{C.leveldb_create_snapshot(db.Ldb)}
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"NewSnapshot",
"(",
")",
"*",
"Snapshot",
"{",
"if",
"db",
".",
"closed",
"{",
"panic",
"(",
"ErrDBClosed",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"Snapshot",
"{",
"C",
".",
"leveldb_create_snapshot",
"(",
"db",
"."... | // NewSnapshot creates a new snapshot of the database.
//
// The Snapshot, when used in a ReadOptions, provides a consistent
// view of state of the database at the the snapshot was created.
//
// To prevent memory leaks and resource strain in the database, the snapshot
// returned must be released with DB.ReleaseSnaps... | [
"NewSnapshot",
"creates",
"a",
"new",
"snapshot",
"of",
"the",
"database",
".",
"The",
"Snapshot",
"when",
"used",
"in",
"a",
"ReadOptions",
"provides",
"a",
"consistent",
"view",
"of",
"state",
"of",
"the",
"database",
"at",
"the",
"the",
"snapshot",
"was",... | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/db.go#L341-L347 |
22,469 | jmhodges/levigo | db.go | ReleaseSnapshot | func (db *DB) ReleaseSnapshot(snap *Snapshot) {
if db.closed {
panic(ErrDBClosed)
}
C.leveldb_release_snapshot(db.Ldb, snap.snap)
} | go | func (db *DB) ReleaseSnapshot(snap *Snapshot) {
if db.closed {
panic(ErrDBClosed)
}
C.leveldb_release_snapshot(db.Ldb, snap.snap)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"ReleaseSnapshot",
"(",
"snap",
"*",
"Snapshot",
")",
"{",
"if",
"db",
".",
"closed",
"{",
"panic",
"(",
"ErrDBClosed",
")",
"\n",
"}",
"\n\n",
"C",
".",
"leveldb_release_snapshot",
"(",
"db",
".",
"Ldb",
",",
"snap... | // ReleaseSnapshot removes the snapshot from the database's list of snapshots,
// and deallocates it. | [
"ReleaseSnapshot",
"removes",
"the",
"snapshot",
"from",
"the",
"database",
"s",
"list",
"of",
"snapshots",
"and",
"deallocates",
"it",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/db.go#L351-L357 |
22,470 | jmhodges/levigo | iterator.go | Seek | func (it *Iterator) Seek(key []byte) {
C.leveldb_iter_seek(it.Iter, (*C.char)(unsafe.Pointer(&key[0])), C.size_t(len(key)))
} | go | func (it *Iterator) Seek(key []byte) {
C.leveldb_iter_seek(it.Iter, (*C.char)(unsafe.Pointer(&key[0])), C.size_t(len(key)))
} | [
"func",
"(",
"it",
"*",
"Iterator",
")",
"Seek",
"(",
"key",
"[",
"]",
"byte",
")",
"{",
"C",
".",
"leveldb_iter_seek",
"(",
"it",
".",
"Iter",
",",
"(",
"*",
"C",
".",
"char",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
"[",
"0",
"]... | // Seek moves the iterator the position of the key given or, if the key
// doesn't exist, the next key that does exist in the database. If the key
// doesn't exist, and there is no next key, the Iterator becomes invalid.
//
// This method is safe to call when Valid returns false. | [
"Seek",
"moves",
"the",
"iterator",
"the",
"position",
"of",
"the",
"key",
"given",
"or",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"the",
"next",
"key",
"that",
"does",
"exist",
"in",
"the",
"database",
".",
"If",
"the",
"key",
"doesn",
"t",
"exist",... | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/iterator.go#L126-L128 |
22,471 | jmhodges/levigo | iterator.go | GetError | func (it *Iterator) GetError() error {
var errStr *C.char
C.leveldb_iter_get_error(it.Iter, &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C.leveldb_free(unsafe.Pointer(errStr))
return IteratorError(gs)
}
return nil
} | go | func (it *Iterator) GetError() error {
var errStr *C.char
C.leveldb_iter_get_error(it.Iter, &errStr)
if errStr != nil {
gs := C.GoString(errStr)
C.leveldb_free(unsafe.Pointer(errStr))
return IteratorError(gs)
}
return nil
} | [
"func",
"(",
"it",
"*",
"Iterator",
")",
"GetError",
"(",
")",
"error",
"{",
"var",
"errStr",
"*",
"C",
".",
"char",
"\n",
"C",
".",
"leveldb_iter_get_error",
"(",
"it",
".",
"Iter",
",",
"&",
"errStr",
")",
"\n",
"if",
"errStr",
"!=",
"nil",
"{",
... | // GetError returns an IteratorError from LevelDB if it had one during
// iteration.
//
// This method is safe to call when Valid returns false. | [
"GetError",
"returns",
"an",
"IteratorError",
"from",
"LevelDB",
"if",
"it",
"had",
"one",
"during",
"iteration",
".",
"This",
"method",
"is",
"safe",
"to",
"call",
"when",
"Valid",
"returns",
"false",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/iterator.go#L134-L143 |
22,472 | jmhodges/levigo | iterator.go | Close | func (it *Iterator) Close() {
C.leveldb_iter_destroy(it.Iter)
it.Iter = nil
} | go | func (it *Iterator) Close() {
C.leveldb_iter_destroy(it.Iter)
it.Iter = nil
} | [
"func",
"(",
"it",
"*",
"Iterator",
")",
"Close",
"(",
")",
"{",
"C",
".",
"leveldb_iter_destroy",
"(",
"it",
".",
"Iter",
")",
"\n",
"it",
".",
"Iter",
"=",
"nil",
"\n",
"}"
] | // Close deallocates the given Iterator, freeing the underlying C struct. | [
"Close",
"deallocates",
"the",
"given",
"Iterator",
"freeing",
"the",
"underlying",
"C",
"struct",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/iterator.go#L146-L149 |
22,473 | jmhodges/levigo | options.go | SetEnv | func (o *Options) SetEnv(env *Env) {
C.leveldb_options_set_env(o.Opt, env.Env)
} | go | func (o *Options) SetEnv(env *Env) {
C.leveldb_options_set_env(o.Opt, env.Env)
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"SetEnv",
"(",
"env",
"*",
"Env",
")",
"{",
"C",
".",
"leveldb_options_set_env",
"(",
"o",
".",
"Opt",
",",
"env",
".",
"Env",
")",
"\n",
"}"
] | // SetEnv sets the Env object for the new database handle. | [
"SetEnv",
"sets",
"the",
"Env",
"object",
"for",
"the",
"new",
"database",
"handle",
"."
] | 853d788c5c416eaaee5b044570784a96c7a26975 | https://github.com/jmhodges/levigo/blob/853d788c5c416eaaee5b044570784a96c7a26975/options.go#L96-L98 |
22,474 | NaySoftware/go-fcm | fcm.go | NewFcmClient | func NewFcmClient(apiKey string) *FcmClient {
fcmc := new(FcmClient)
fcmc.ApiKey = apiKey
return fcmc
} | go | func NewFcmClient(apiKey string) *FcmClient {
fcmc := new(FcmClient)
fcmc.ApiKey = apiKey
return fcmc
} | [
"func",
"NewFcmClient",
"(",
"apiKey",
"string",
")",
"*",
"FcmClient",
"{",
"fcmc",
":=",
"new",
"(",
"FcmClient",
")",
"\n",
"fcmc",
".",
"ApiKey",
"=",
"apiKey",
"\n\n",
"return",
"fcmc",
"\n",
"}"
] | // NewFcmClient init and create fcm client | [
"NewFcmClient",
"init",
"and",
"create",
"fcm",
"client"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L93-L98 |
22,475 | NaySoftware/go-fcm | fcm.go | SetMsgData | func (this *FcmClient) SetMsgData(body interface{}) *FcmClient {
this.Message.Data = body
return this
} | go | func (this *FcmClient) SetMsgData(body interface{}) *FcmClient {
this.Message.Data = body
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetMsgData",
"(",
"body",
"interface",
"{",
"}",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"Data",
"=",
"body",
"\n\n",
"return",
"this",
"\n\n",
"}"
] | // SetMsgData sets data payload | [
"SetMsgData",
"sets",
"data",
"payload"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L117-L123 |
22,476 | NaySoftware/go-fcm | fcm.go | NewFcmRegIdsMsg | func (this *FcmClient) NewFcmRegIdsMsg(list []string, body interface{}) *FcmClient {
this.newDevicesList(list)
this.Message.Data = body
return this
} | go | func (this *FcmClient) NewFcmRegIdsMsg(list []string, body interface{}) *FcmClient {
this.newDevicesList(list)
this.Message.Data = body
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"NewFcmRegIdsMsg",
"(",
"list",
"[",
"]",
"string",
",",
"body",
"interface",
"{",
"}",
")",
"*",
"FcmClient",
"{",
"this",
".",
"newDevicesList",
"(",
"list",
")",
"\n",
"this",
".",
"Message",
".",
"Data",
... | // NewFcmRegIdsMsg gets a list of devices with data payload | [
"NewFcmRegIdsMsg",
"gets",
"a",
"list",
"of",
"devices",
"with",
"data",
"payload"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L126-L132 |
22,477 | NaySoftware/go-fcm | fcm.go | newDevicesList | func (this *FcmClient) newDevicesList(list []string) *FcmClient {
this.Message.RegistrationIds = make([]string, len(list))
copy(this.Message.RegistrationIds, list)
return this
} | go | func (this *FcmClient) newDevicesList(list []string) *FcmClient {
this.Message.RegistrationIds = make([]string, len(list))
copy(this.Message.RegistrationIds, list)
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"newDevicesList",
"(",
"list",
"[",
"]",
"string",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"RegistrationIds",
"=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"list",
")",
")",
"\n",
... | // newDevicesList init the devices list | [
"newDevicesList",
"init",
"the",
"devices",
"list"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L135-L141 |
22,478 | NaySoftware/go-fcm | fcm.go | sendOnce | func (this *FcmClient) sendOnce() (*FcmResponseStatus, error) {
fcmRespStatus := new(FcmResponseStatus)
jsonByte, err := this.Message.toJsonByte()
if err != nil {
return fcmRespStatus, err
}
request, err := http.NewRequest("POST", fcmServerUrl, bytes.NewBuffer(jsonByte))
request.Header.Set("Authorization", t... | go | func (this *FcmClient) sendOnce() (*FcmResponseStatus, error) {
fcmRespStatus := new(FcmResponseStatus)
jsonByte, err := this.Message.toJsonByte()
if err != nil {
return fcmRespStatus, err
}
request, err := http.NewRequest("POST", fcmServerUrl, bytes.NewBuffer(jsonByte))
request.Header.Set("Authorization", t... | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"sendOnce",
"(",
")",
"(",
"*",
"FcmResponseStatus",
",",
"error",
")",
"{",
"fcmRespStatus",
":=",
"new",
"(",
"FcmResponseStatus",
")",
"\n\n",
"jsonByte",
",",
"err",
":=",
"this",
".",
"Message",
".",
"toJs... | // sendOnce send a single request to fcm | [
"sendOnce",
"send",
"a",
"single",
"request",
"to",
"fcm"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L157-L198 |
22,479 | NaySoftware/go-fcm | fcm.go | parseStatusBody | func (this *FcmResponseStatus) parseStatusBody(body []byte) error {
if err := json.Unmarshal([]byte(body), &this); err != nil {
return err
}
return nil
} | go | func (this *FcmResponseStatus) parseStatusBody(body []byte) error {
if err := json.Unmarshal([]byte(body), &this); err != nil {
return err
}
return nil
} | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"parseStatusBody",
"(",
"body",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"body",
")",
",",
"&",
"this",
")",
";",
"err",
"!=",
... | // parseStatusBody parse FCM response body | [
"parseStatusBody",
"parse",
"FCM",
"response",
"body"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L214-L221 |
22,480 | NaySoftware/go-fcm | fcm.go | SetPriority | func (this *FcmClient) SetPriority(p string) *FcmClient {
if p == Priority_HIGH {
this.Message.Priority = Priority_HIGH
} else {
this.Message.Priority = Priority_NORMAL
}
return this
} | go | func (this *FcmClient) SetPriority(p string) *FcmClient {
if p == Priority_HIGH {
this.Message.Priority = Priority_HIGH
} else {
this.Message.Priority = Priority_NORMAL
}
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetPriority",
"(",
"p",
"string",
")",
"*",
"FcmClient",
"{",
"if",
"p",
"==",
"Priority_HIGH",
"{",
"this",
".",
"Message",
".",
"Priority",
"=",
"Priority_HIGH",
"\n",
"}",
"else",
"{",
"this",
".",
"Messa... | // SetPriority Sets the priority of the message.
// Priority_HIGH or Priority_NORMAL | [
"SetPriority",
"Sets",
"the",
"priority",
"of",
"the",
"message",
".",
"Priority_HIGH",
"or",
"Priority_NORMAL"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L225-L234 |
22,481 | NaySoftware/go-fcm | fcm.go | SetContentAvailable | func (this *FcmClient) SetContentAvailable(isContentAvailable bool) *FcmClient {
this.Message.ContentAvailable = isContentAvailable
return this
} | go | func (this *FcmClient) SetContentAvailable(isContentAvailable bool) *FcmClient {
this.Message.ContentAvailable = isContentAvailable
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetContentAvailable",
"(",
"isContentAvailable",
"bool",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"ContentAvailable",
"=",
"isContentAvailable",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetContentAvailable On iOS, use this field to represent content-available
// in the APNS payload. When a notification or message is sent and this is set
// to true, an inactive client app is awoken. On Android, data messages wake
// the app by default. On Chrome, currently not supported. | [
"SetContentAvailable",
"On",
"iOS",
"use",
"this",
"field",
"to",
"represent",
"content",
"-",
"available",
"in",
"the",
"APNS",
"payload",
".",
"When",
"a",
"notification",
"or",
"message",
"is",
"sent",
"and",
"this",
"is",
"set",
"to",
"true",
"an",
"in... | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L261-L266 |
22,482 | NaySoftware/go-fcm | fcm.go | SetDelayWhileIdle | func (this *FcmClient) SetDelayWhileIdle(isDelayWhileIdle bool) *FcmClient {
this.Message.DelayWhileIdle = isDelayWhileIdle
return this
} | go | func (this *FcmClient) SetDelayWhileIdle(isDelayWhileIdle bool) *FcmClient {
this.Message.DelayWhileIdle = isDelayWhileIdle
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetDelayWhileIdle",
"(",
"isDelayWhileIdle",
"bool",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"DelayWhileIdle",
"=",
"isDelayWhileIdle",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetDelayWhileIdle When this parameter is set to true, it indicates that
// the message should not be sent until the device becomes active.
// The default value is false. | [
"SetDelayWhileIdle",
"When",
"this",
"parameter",
"is",
"set",
"to",
"true",
"it",
"indicates",
"that",
"the",
"message",
"should",
"not",
"be",
"sent",
"until",
"the",
"device",
"becomes",
"active",
".",
"The",
"default",
"value",
"is",
"false",
"."
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L271-L276 |
22,483 | NaySoftware/go-fcm | fcm.go | SetRestrictedPackageName | func (this *FcmClient) SetRestrictedPackageName(pkg string) *FcmClient {
this.Message.RestrictedPackageName = pkg
return this
} | go | func (this *FcmClient) SetRestrictedPackageName(pkg string) *FcmClient {
this.Message.RestrictedPackageName = pkg
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetRestrictedPackageName",
"(",
"pkg",
"string",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"RestrictedPackageName",
"=",
"pkg",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetRestrictedPackageName This parameter specifies the package name of the
// application where the registration tokens must match in order to
// receive the message. | [
"SetRestrictedPackageName",
"This",
"parameter",
"specifies",
"the",
"package",
"name",
"of",
"the",
"application",
"where",
"the",
"registration",
"tokens",
"must",
"match",
"in",
"order",
"to",
"receive",
"the",
"message",
"."
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L300-L305 |
22,484 | NaySoftware/go-fcm | fcm.go | SetDryRun | func (this *FcmClient) SetDryRun(drun bool) *FcmClient {
this.Message.DryRun = drun
return this
} | go | func (this *FcmClient) SetDryRun(drun bool) *FcmClient {
this.Message.DryRun = drun
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetDryRun",
"(",
"drun",
"bool",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"DryRun",
"=",
"drun",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetDryRun This parameter, when set to true, allows developers to test
// a request without actually sending a message.
// The default value is false | [
"SetDryRun",
"This",
"parameter",
"when",
"set",
"to",
"true",
"allows",
"developers",
"to",
"test",
"a",
"request",
"without",
"actually",
"sending",
"a",
"message",
".",
"The",
"default",
"value",
"is",
"false"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L310-L315 |
22,485 | NaySoftware/go-fcm | fcm.go | SetMutableContent | func (this *FcmClient) SetMutableContent(mc bool) *FcmClient {
this.Message.MutableContent = mc
return this
} | go | func (this *FcmClient) SetMutableContent(mc bool) *FcmClient {
this.Message.MutableContent = mc
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetMutableContent",
"(",
"mc",
"bool",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"MutableContent",
"=",
"mc",
"\n\n",
"return",
"this",
"\n",
"}"
] | // SetMutableContent Currently for iOS 10+ devices only. On iOS,
// use this field to represent mutable-content in the APNs payload.
// When a notification is sent and this is set to true, the content
// of the notification can be modified before it is displayed,
// using a Notification Service app extension.
// This p... | [
"SetMutableContent",
"Currently",
"for",
"iOS",
"10",
"+",
"devices",
"only",
".",
"On",
"iOS",
"use",
"this",
"field",
"to",
"represent",
"mutable",
"-",
"content",
"in",
"the",
"APNs",
"payload",
".",
"When",
"a",
"notification",
"is",
"sent",
"and",
"th... | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L323-L328 |
22,486 | NaySoftware/go-fcm | fcm.go | PrintResults | func (this *FcmResponseStatus) PrintResults() {
fmt.Println("Status Code :", this.StatusCode)
fmt.Println("Success :", this.Success)
fmt.Println("Fail :", this.Fail)
fmt.Println("Canonical_ids :", this.Canonical_ids)
fmt.Println("Topic MsgId :", this.MsgId)
fmt.Println("Topic Err :", this.E... | go | func (this *FcmResponseStatus) PrintResults() {
fmt.Println("Status Code :", this.StatusCode)
fmt.Println("Success :", this.Success)
fmt.Println("Fail :", this.Fail)
fmt.Println("Canonical_ids :", this.Canonical_ids)
fmt.Println("Topic MsgId :", this.MsgId)
fmt.Println("Topic Err :", this.E... | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"StatusCode",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Success",
")",
"\n",
"f... | // PrintResults prints the FcmResponseStatus results for fast using and debugging | [
"PrintResults",
"prints",
"the",
"FcmResponseStatus",
"results",
"for",
"fast",
"using",
"and",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L331-L344 |
22,487 | NaySoftware/go-fcm | fcm.go | IsTimeout | func (this *FcmResponseStatus) IsTimeout() bool {
if this.StatusCode >= 500 {
return true
} else if this.StatusCode == 200 {
for _, val := range this.Results {
for k, v := range val {
if k == error_key && retreyableErrors[v] == true {
return true
}
}
}
}
return false
} | go | func (this *FcmResponseStatus) IsTimeout() bool {
if this.StatusCode >= 500 {
return true
} else if this.StatusCode == 200 {
for _, val := range this.Results {
for k, v := range val {
if k == error_key && retreyableErrors[v] == true {
return true
}
}
}
}
return false
} | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"IsTimeout",
"(",
")",
"bool",
"{",
"if",
"this",
".",
"StatusCode",
">=",
"500",
"{",
"return",
"true",
"\n",
"}",
"else",
"if",
"this",
".",
"StatusCode",
"==",
"200",
"{",
"for",
"_",
",",
"val",... | // IsTimeout check whether the response timeout based on http response status
// code and if any error is retryable | [
"IsTimeout",
"check",
"whether",
"the",
"response",
"timeout",
"based",
"on",
"http",
"response",
"status",
"code",
"and",
"if",
"any",
"error",
"is",
"retryable"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L348-L362 |
22,488 | NaySoftware/go-fcm | fcm.go | GetRetryAfterTime | func (this *FcmResponseStatus) GetRetryAfterTime() (t time.Duration, e error) {
t, e = time.ParseDuration(this.RetryAfter)
return
} | go | func (this *FcmResponseStatus) GetRetryAfterTime() (t time.Duration, e error) {
t, e = time.ParseDuration(this.RetryAfter)
return
} | [
"func",
"(",
"this",
"*",
"FcmResponseStatus",
")",
"GetRetryAfterTime",
"(",
")",
"(",
"t",
"time",
".",
"Duration",
",",
"e",
"error",
")",
"{",
"t",
",",
"e",
"=",
"time",
".",
"ParseDuration",
"(",
"this",
".",
"RetryAfter",
")",
"\n",
"return",
... | // GetRetryAfterTime converts the retrey after response header
// to a time.Duration | [
"GetRetryAfterTime",
"converts",
"the",
"retrey",
"after",
"response",
"header",
"to",
"a",
"time",
".",
"Duration"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L366-L369 |
22,489 | NaySoftware/go-fcm | fcm.go | SetCondition | func (this *FcmClient) SetCondition(condition string) *FcmClient {
this.Message.Condition = condition
return this
} | go | func (this *FcmClient) SetCondition(condition string) *FcmClient {
this.Message.Condition = condition
return this
} | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"SetCondition",
"(",
"condition",
"string",
")",
"*",
"FcmClient",
"{",
"this",
".",
"Message",
".",
"Condition",
"=",
"condition",
"\n",
"return",
"this",
"\n",
"}"
] | // SetCondition to set a logical expression of conditions that determine the message target | [
"SetCondition",
"to",
"set",
"a",
"logical",
"expression",
"of",
"conditions",
"that",
"determine",
"the",
"message",
"target"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/fcm.go#L372-L375 |
22,490 | NaySoftware/go-fcm | instanceid.go | GetInfo | func (this *FcmClient) GetInfo(withDetails bool, instanceIdToken string) (*InstanceIdInfoResponse, error) {
var request_url string = generateGetInfoUrl(instance_id_info_no_details_srv_url, instanceIdToken)
if withDetails == true {
request_url = generateGetInfoUrl(instance_id_info_with_details_srv_url, instanceIdT... | go | func (this *FcmClient) GetInfo(withDetails bool, instanceIdToken string) (*InstanceIdInfoResponse, error) {
var request_url string = generateGetInfoUrl(instance_id_info_no_details_srv_url, instanceIdToken)
if withDetails == true {
request_url = generateGetInfoUrl(instance_id_info_with_details_srv_url, instanceIdT... | [
"func",
"(",
"this",
"*",
"FcmClient",
")",
"GetInfo",
"(",
"withDetails",
"bool",
",",
"instanceIdToken",
"string",
")",
"(",
"*",
"InstanceIdInfoResponse",
",",
"error",
")",
"{",
"var",
"request_url",
"string",
"=",
"generateGetInfoUrl",
"(",
"instance_id_inf... | // GetInfo gets the instance id info | [
"GetInfo",
"gets",
"the",
"instance",
"id",
"info"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L104-L139 |
22,491 | NaySoftware/go-fcm | instanceid.go | parseGetInfo | func parseGetInfo(body []byte) (*InstanceIdInfoResponse, error) {
info := new(InstanceIdInfoResponse)
if err := json.Unmarshal([]byte(body), &info); err != nil {
return nil, err
}
return info, nil
} | go | func parseGetInfo(body []byte) (*InstanceIdInfoResponse, error) {
info := new(InstanceIdInfoResponse)
if err := json.Unmarshal([]byte(body), &info); err != nil {
return nil, err
}
return info, nil
} | [
"func",
"parseGetInfo",
"(",
"body",
"[",
"]",
"byte",
")",
"(",
"*",
"InstanceIdInfoResponse",
",",
"error",
")",
"{",
"info",
":=",
"new",
"(",
"InstanceIdInfoResponse",
")",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
... | // parseGetInfo parses response to InstanceIdInfoResponse | [
"parseGetInfo",
"parses",
"response",
"to",
"InstanceIdInfoResponse"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L142-L152 |
22,492 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *InstanceIdInfoResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("App : ", this.Application)
fmt.Println("Auth : ", this.AuthorizedEntity)
fmt.Println("Ver : ", this.ApplicationVersion)
fmt.Println("Sig : ", this.AppSigner)
fmt.Println("Att : ",... | go | func (this *InstanceIdInfoResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("App : ", this.Application)
fmt.Println("Auth : ", this.AuthorizedEntity)
fmt.Println("Ver : ", this.ApplicationVersion)
fmt.Println("Sig : ", this.AppSigner)
fmt.Println("Att : ",... | [
"func",
"(",
"this",
"*",
"InstanceIdInfoResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Error",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Application",
")",
"\n",
... | // PrintResults prints InstanceIdInfoResponse, for faster debugging | [
"PrintResults",
"prints",
"InstanceIdInfoResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L155-L173 |
22,493 | NaySoftware/go-fcm | instanceid.go | generateGetInfoUrl | func generateGetInfoUrl(srv string, instanceIdToken string) string {
return fmt.Sprintf(srv, instanceIdToken)
} | go | func generateGetInfoUrl(srv string, instanceIdToken string) string {
return fmt.Sprintf(srv, instanceIdToken)
} | [
"func",
"generateGetInfoUrl",
"(",
"srv",
"string",
",",
"instanceIdToken",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"srv",
",",
"instanceIdToken",
")",
"\n",
"}"
] | // generateGetInfoUrl generate based on with details and the instance token | [
"generateGetInfoUrl",
"generate",
"based",
"on",
"with",
"details",
"and",
"the",
"instance",
"token"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L176-L178 |
22,494 | NaySoftware/go-fcm | instanceid.go | parseSubscribeResponse | func parseSubscribeResponse(body []byte, resp *http.Response) (*SubscribeResponse, error) {
subResp := new(SubscribeResponse)
subResp.Status = resp.Status
subResp.StatusCode = resp.StatusCode
if err := json.Unmarshal(body, &subResp); err != nil {
return nil, err
}
return subResp, nil
} | go | func parseSubscribeResponse(body []byte, resp *http.Response) (*SubscribeResponse, error) {
subResp := new(SubscribeResponse)
subResp.Status = resp.Status
subResp.StatusCode = resp.StatusCode
if err := json.Unmarshal(body, &subResp); err != nil {
return nil, err
}
return subResp, nil
} | [
"func",
"parseSubscribeResponse",
"(",
"body",
"[",
"]",
"byte",
",",
"resp",
"*",
"http",
".",
"Response",
")",
"(",
"*",
"SubscribeResponse",
",",
"error",
")",
"{",
"subResp",
":=",
"new",
"(",
"SubscribeResponse",
")",
"\n\n",
"subResp",
".",
"Status",... | // parseSubscribeResponse converts a byte response to a SubscribeResponse | [
"parseSubscribeResponse",
"converts",
"a",
"byte",
"response",
"to",
"a",
"SubscribeResponse"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L213-L224 |
22,495 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *SubscribeResponse) PrintResults() {
fmt.Println("Response Status: ", this.Status)
fmt.Println("Response Code : ", this.StatusCode)
if this.StatusCode != 200 {
fmt.Println("Error : ", this.Error)
}
} | go | func (this *SubscribeResponse) PrintResults() {
fmt.Println("Response Status: ", this.Status)
fmt.Println("Response Code : ", this.StatusCode)
if this.StatusCode != 200 {
fmt.Println("Error : ", this.Error)
}
} | [
"func",
"(",
"this",
"*",
"SubscribeResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Status",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"StatusCode",
")",
"\n",
"if... | // PrintResults prints SubscribeResponse, for faster debugging | [
"PrintResults",
"prints",
"SubscribeResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L227-L235 |
22,496 | NaySoftware/go-fcm | instanceid.go | generateSubToTopicUrl | func generateSubToTopicUrl(instaceId string, topic string) string {
Tmptopic := strings.ToLower(topic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(topic, "/")
topic = tmp[len(tmp)-1]
}
return fmt.Sprintf(subscribe_instanceid_to_topic_srv_url, instaceId, topic)
} | go | func generateSubToTopicUrl(instaceId string, topic string) string {
Tmptopic := strings.ToLower(topic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(topic, "/")
topic = tmp[len(tmp)-1]
}
return fmt.Sprintf(subscribe_instanceid_to_topic_srv_url, instaceId, topic)
} | [
"func",
"generateSubToTopicUrl",
"(",
"instaceId",
"string",
",",
"topic",
"string",
")",
"string",
"{",
"Tmptopic",
":=",
"strings",
".",
"ToLower",
"(",
"topic",
")",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"Tmptopic",
",",
"\"",
"\"",
")",
"{",
"... | // generateSubToTopicUrl generates a url based on the instnace id and topic name | [
"generateSubToTopicUrl",
"generates",
"a",
"url",
"based",
"on",
"the",
"instnace",
"id",
"and",
"topic",
"name"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L238-L245 |
22,497 | NaySoftware/go-fcm | instanceid.go | PrintResults | func (this *BatchResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("Status : ", this.Status)
fmt.Println("Status Code : ", this.StatusCode)
for i, val := range this.Results {
if batchErrors[val["error"]] == true {
fmt.Println("ID: ", i, " | ", val["error"])
}
}
} | go | func (this *BatchResponse) PrintResults() {
fmt.Println("Error : ", this.Error)
fmt.Println("Status : ", this.Status)
fmt.Println("Status Code : ", this.StatusCode)
for i, val := range this.Results {
if batchErrors[val["error"]] == true {
fmt.Println("ID: ", i, " | ", val["error"])
}
}
} | [
"func",
"(",
"this",
"*",
"BatchResponse",
")",
"PrintResults",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Error",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"this",
".",
"Status",
")",
"\n",
"fmt",
"."... | // PrintResults prints BatchResponse, for faster debugging | [
"PrintResults",
"prints",
"BatchResponse",
"for",
"faster",
"debugging"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L331-L340 |
22,498 | NaySoftware/go-fcm | instanceid.go | generateBatchRequest | func generateBatchRequest(tokens []string, topic string) ([]byte, error) {
envelope := new(BatchRequest)
envelope.To = topics + extractTopicName(topic)
envelope.RegTokens = make([]string, len(tokens))
copy(envelope.RegTokens, tokens)
return json.Marshal(envelope)
} | go | func generateBatchRequest(tokens []string, topic string) ([]byte, error) {
envelope := new(BatchRequest)
envelope.To = topics + extractTopicName(topic)
envelope.RegTokens = make([]string, len(tokens))
copy(envelope.RegTokens, tokens)
return json.Marshal(envelope)
} | [
"func",
"generateBatchRequest",
"(",
"tokens",
"[",
"]",
"string",
",",
"topic",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"envelope",
":=",
"new",
"(",
"BatchRequest",
")",
"\n",
"envelope",
".",
"To",
"=",
"topics",
"+",
"extractT... | // generateBatchRequest based on tokens and topic | [
"generateBatchRequest",
"based",
"on",
"tokens",
"and",
"topic"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L343-L351 |
22,499 | NaySoftware/go-fcm | instanceid.go | extractTopicName | func extractTopicName(inTopic string) (result string) {
Tmptopic := strings.ToLower(inTopic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(inTopic, "/")
result = tmp[len(tmp)-1]
return
}
result = inTopic
return
} | go | func extractTopicName(inTopic string) (result string) {
Tmptopic := strings.ToLower(inTopic)
if strings.Contains(Tmptopic, "/topics/") {
tmp := strings.Split(inTopic, "/")
result = tmp[len(tmp)-1]
return
}
result = inTopic
return
} | [
"func",
"extractTopicName",
"(",
"inTopic",
"string",
")",
"(",
"result",
"string",
")",
"{",
"Tmptopic",
":=",
"strings",
".",
"ToLower",
"(",
"inTopic",
")",
"\n",
"if",
"strings",
".",
"Contains",
"(",
"Tmptopic",
",",
"\"",
"\"",
")",
"{",
"tmp",
"... | // extractTopicName extract topic name for valid topic name input | [
"extractTopicName",
"extract",
"topic",
"name",
"for",
"valid",
"topic",
"name",
"input"
] | 28fff9381d17f35619309c7a5ada41d26030d976 | https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L354-L364 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.