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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
144,400 | ipfs/go-datastore | autobatch/autobatch.go | Query | func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
err := d.Flush()
if err != nil {
return nil, err
}
return d.child.Query(q)
} | go | func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
err := d.Flush()
if err != nil {
return nil, err
}
return d.child.Query(q)
} | [
"func",
"(",
"d",
"*",
"Datastore",
")",
"Query",
"(",
"q",
"dsq",
".",
"Query",
")",
"(",
"dsq",
".",
"Results",
",",
"error",
")",
"{",
"err",
":=",
"d",
".",
"Flush",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // Query performs a query | [
"Query",
"performs",
"a",
"query"
] | aa9190c18f1576be98e974359fd08c64ca0b5a94 | https://github.com/ipfs/go-datastore/blob/aa9190c18f1576be98e974359fd08c64ca0b5a94/autobatch/autobatch.go#L119-L126 |
144,401 | apache/qpid-proton | go/src/qpid.apache.org/electron/receiver.go | newReceiver | func newReceiver(ls linkSettings) *receiver {
r := &receiver{link: link{linkSettings: ls}}
r.endpoint.init(r.link.pLink.String())
if r.capacity < 1 {
r.capacity = 1
}
r.buffer = make(chan ReceivedMessage, r.capacity)
r.handler().addLink(r.pLink, r)
r.link.pLink.Open()
if r.prefetch {
r.flow(r.maxFlow())
}
... | go | func newReceiver(ls linkSettings) *receiver {
r := &receiver{link: link{linkSettings: ls}}
r.endpoint.init(r.link.pLink.String())
if r.capacity < 1 {
r.capacity = 1
}
r.buffer = make(chan ReceivedMessage, r.capacity)
r.handler().addLink(r.pLink, r)
r.link.pLink.Open()
if r.prefetch {
r.flow(r.maxFlow())
}
... | [
"func",
"newReceiver",
"(",
"ls",
"linkSettings",
")",
"*",
"receiver",
"{",
"r",
":=",
"&",
"receiver",
"{",
"link",
":",
"link",
"{",
"linkSettings",
":",
"ls",
"}",
"}",
"\n",
"r",
".",
"endpoint",
".",
"init",
"(",
"r",
".",
"link",
".",
"pLink... | // Call in proton goroutine | [
"Call",
"in",
"proton",
"goroutine"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/receiver.go#L80-L93 |
144,402 | apache/qpid-proton | go/src/qpid.apache.org/electron/receiver.go | caller | func (r *receiver) caller(inc int) {
_ = r.engine().Inject(func() {
r.callers += inc
need := r.callers - (len(r.buffer) + r.pLink.Credit())
max := r.maxFlow()
if need > max {
need = max
}
r.flow(need)
})
} | go | func (r *receiver) caller(inc int) {
_ = r.engine().Inject(func() {
r.callers += inc
need := r.callers - (len(r.buffer) + r.pLink.Credit())
max := r.maxFlow()
if need > max {
need = max
}
r.flow(need)
})
} | [
"func",
"(",
"r",
"*",
"receiver",
")",
"caller",
"(",
"inc",
"int",
")",
"{",
"_",
"=",
"r",
".",
"engine",
"(",
")",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"r",
".",
"callers",
"+=",
"inc",
"\n",
"need",
":=",
"r",
".",
"callers",
"-",
... | // Inject flow check per-caller call when prefetch is off.
// Called with inc=1 at start of call, inc = -1 at end | [
"Inject",
"flow",
"check",
"per",
"-",
"caller",
"call",
"when",
"prefetch",
"is",
"off",
".",
"Called",
"with",
"inc",
"=",
"1",
"at",
"start",
"of",
"call",
"inc",
"=",
"-",
"1",
"at",
"end"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/receiver.go#L106-L116 |
144,403 | apache/qpid-proton | go/src/qpid.apache.org/electron/receiver.go | flowTopUp | func (r *receiver) flowTopUp() {
if r.prefetch {
_ = r.engine().Inject(func() { r.flow(r.maxFlow()) })
}
} | go | func (r *receiver) flowTopUp() {
if r.prefetch {
_ = r.engine().Inject(func() { r.flow(r.maxFlow()) })
}
} | [
"func",
"(",
"r",
"*",
"receiver",
")",
"flowTopUp",
"(",
")",
"{",
"if",
"r",
".",
"prefetch",
"{",
"_",
"=",
"r",
".",
"engine",
"(",
")",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"r",
".",
"flow",
"(",
"r",
".",
"maxFlow",
"(",
")",
")... | // Inject flow top-up if prefetch is enabled | [
"Inject",
"flow",
"top",
"-",
"up",
"if",
"prefetch",
"is",
"enabled"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/receiver.go#L119-L123 |
144,404 | apache/qpid-proton | go/src/qpid.apache.org/electron/receiver.go | message | func (r *receiver) message(delivery proton.Delivery) {
if r.pLink.State().RemoteClosed() {
localClose(r.pLink, r.pLink.RemoteCondition().Error())
return
}
if delivery.HasMessage() {
bytes, err := delivery.MessageBytes()
var m amqp.Message
if err == nil {
m = amqp.NewMessage()
err = r.session.connecti... | go | func (r *receiver) message(delivery proton.Delivery) {
if r.pLink.State().RemoteClosed() {
localClose(r.pLink, r.pLink.RemoteCondition().Error())
return
}
if delivery.HasMessage() {
bytes, err := delivery.MessageBytes()
var m amqp.Message
if err == nil {
m = amqp.NewMessage()
err = r.session.connecti... | [
"func",
"(",
"r",
"*",
"receiver",
")",
"message",
"(",
"delivery",
"proton",
".",
"Delivery",
")",
"{",
"if",
"r",
".",
"pLink",
".",
"State",
"(",
")",
".",
"RemoteClosed",
"(",
")",
"{",
"localClose",
"(",
"r",
".",
"pLink",
",",
"r",
".",
"pL... | // Called in proton goroutine on MMessage event. | [
"Called",
"in",
"proton",
"goroutine",
"on",
"MMessage",
"event",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/receiver.go#L159-L183 |
144,405 | apache/qpid-proton | go/src/qpid.apache.org/electron/receiver.go | acknowledge | func (rm *ReceivedMessage) acknowledge(status uint64) error {
return rm.receiver.(*receiver).engine().Inject(func() {
// Deliveries are valid as long as the connection is, unless settled.
rm.pDelivery.SettleAs(uint64(status))
})
} | go | func (rm *ReceivedMessage) acknowledge(status uint64) error {
return rm.receiver.(*receiver).engine().Inject(func() {
// Deliveries are valid as long as the connection is, unless settled.
rm.pDelivery.SettleAs(uint64(status))
})
} | [
"func",
"(",
"rm",
"*",
"ReceivedMessage",
")",
"acknowledge",
"(",
"status",
"uint64",
")",
"error",
"{",
"return",
"rm",
".",
"receiver",
".",
"(",
"*",
"receiver",
")",
".",
"engine",
"(",
")",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"// Delive... | // Acknowledge a ReceivedMessage with the given delivery status. | [
"Acknowledge",
"a",
"ReceivedMessage",
"with",
"the",
"given",
"delivery",
"status",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/receiver.go#L203-L208 |
144,406 | apache/qpid-proton | go/src/qpid.apache.org/electron/receiver.go | Accept | func (in *IncomingReceiver) Accept() Endpoint {
return in.accept(func() Endpoint { return newReceiver(in.linkSettings) })
} | go | func (in *IncomingReceiver) Accept() Endpoint {
return in.accept(func() Endpoint { return newReceiver(in.linkSettings) })
} | [
"func",
"(",
"in",
"*",
"IncomingReceiver",
")",
"Accept",
"(",
")",
"Endpoint",
"{",
"return",
"in",
".",
"accept",
"(",
"func",
"(",
")",
"Endpoint",
"{",
"return",
"newReceiver",
"(",
"in",
".",
"linkSettings",
")",
"}",
")",
"\n",
"}"
] | // Accept accepts an incoming receiver endpoint | [
"Accept",
"accepts",
"an",
"incoming",
"receiver",
"endpoint"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/receiver.go#L241-L243 |
144,407 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | EndpointError | func EndpointError(e Endpoint) error {
err := e.RemoteCondition().Error()
if err == nil {
err = e.Condition().Error()
}
return err
} | go | func EndpointError(e Endpoint) error {
err := e.RemoteCondition().Error()
if err == nil {
err = e.Condition().Error()
}
return err
} | [
"func",
"EndpointError",
"(",
"e",
"Endpoint",
")",
"error",
"{",
"err",
":=",
"e",
".",
"RemoteCondition",
"(",
")",
".",
"Error",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"err",
"=",
"e",
".",
"Condition",
"(",
")",
".",
"Error",
"(",
")"... | // EndpointError returns the remote error if there is one, the local error if not
// nil if there is no error. | [
"EndpointError",
"returns",
"the",
"remote",
"error",
"if",
"there",
"is",
"one",
"the",
"local",
"error",
"if",
"not",
"nil",
"if",
"there",
"is",
"no",
"error",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L206-L212 |
144,408 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | Release | func (d Delivery) Release(delivered bool) {
if delivered {
d.SettleAs(Modified)
} else {
d.SettleAs(Released)
}
} | go | func (d Delivery) Release(delivered bool) {
if delivered {
d.SettleAs(Modified)
} else {
d.SettleAs(Released)
}
} | [
"func",
"(",
"d",
"Delivery",
")",
"Release",
"(",
"delivered",
"bool",
")",
"{",
"if",
"delivered",
"{",
"d",
".",
"SettleAs",
"(",
"Modified",
")",
"\n",
"}",
"else",
"{",
"d",
".",
"SettleAs",
"(",
"Released",
")",
"\n",
"}",
"\n",
"}"
] | // Release releases and settles a delivery
// If delivered is true the delivery count for the message will be increased. | [
"Release",
"releases",
"and",
"settles",
"a",
"delivery",
"If",
"delivered",
"is",
"true",
"the",
"delivery",
"count",
"for",
"the",
"message",
"will",
"be",
"increased",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L236-L242 |
144,409 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | String | func (l Link) String() string {
switch {
case l.IsNil():
return fmt.Sprintf("<nil-link>")
case l.IsSender():
return fmt.Sprintf("%s(%s->%s)", l.Name(), l.Source().Address(), l.Target().Address())
default:
return fmt.Sprintf("%s(%s<-%s)", l.Name(), l.Target().Address(), l.Source().Address())
}
} | go | func (l Link) String() string {
switch {
case l.IsNil():
return fmt.Sprintf("<nil-link>")
case l.IsSender():
return fmt.Sprintf("%s(%s->%s)", l.Name(), l.Source().Address(), l.Target().Address())
default:
return fmt.Sprintf("%s(%s<-%s)", l.Name(), l.Target().Address(), l.Source().Address())
}
} | [
"func",
"(",
"l",
"Link",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"{",
"case",
"l",
".",
"IsNil",
"(",
")",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
")",
"\n",
"case",
"l",
".",
"IsSender",
"(",
")",
":",
"return",
"fmt"... | // Human-readable link description including name, source, target and direction. | [
"Human",
"-",
"readable",
"link",
"description",
"including",
"name",
"source",
"target",
"and",
"direction",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L271-L280 |
144,410 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | LinkHead | func (c Connection) LinkHead(s State) Link {
return Link{C.pn_link_head(c.pn, C.pn_state_t(s))}
} | go | func (c Connection) LinkHead(s State) Link {
return Link{C.pn_link_head(c.pn, C.pn_state_t(s))}
} | [
"func",
"(",
"c",
"Connection",
")",
"LinkHead",
"(",
"s",
"State",
")",
"Link",
"{",
"return",
"Link",
"{",
"C",
".",
"pn_link_head",
"(",
"c",
".",
"pn",
",",
"C",
".",
"pn_state_t",
"(",
"s",
")",
")",
"}",
"\n",
"}"
] | // Head functions don't follow the normal naming conventions so missed by the generator. | [
"Head",
"functions",
"don",
"t",
"follow",
"the",
"normal",
"naming",
"conventions",
"so",
"missed",
"by",
"the",
"generator",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L334-L336 |
144,411 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | Error | func (c Condition) Error() error {
if c.IsNil() || !c.IsSet() {
return nil
}
return amqp.Error{Name: c.Name(), Description: c.Description()}
} | go | func (c Condition) Error() error {
if c.IsNil() || !c.IsSet() {
return nil
}
return amqp.Error{Name: c.Name(), Description: c.Description()}
} | [
"func",
"(",
"c",
"Condition",
")",
"Error",
"(",
")",
"error",
"{",
"if",
"c",
".",
"IsNil",
"(",
")",
"||",
"!",
"c",
".",
"IsSet",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"amqp",
".",
"Error",
"{",
"Name",
":",
"c",
".",... | // Error returns an instance of amqp.Error or nil. | [
"Error",
"returns",
"an",
"instance",
"of",
"amqp",
".",
"Error",
"or",
"nil",
"."
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L375-L380 |
144,412 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | SetError | func (c Condition) SetError(err error) {
if err != nil {
cond := amqp.MakeError(err)
c.SetName(cond.Name)
c.SetDescription(cond.Description)
}
} | go | func (c Condition) SetError(err error) {
if err != nil {
cond := amqp.MakeError(err)
c.SetName(cond.Name)
c.SetDescription(cond.Description)
}
} | [
"func",
"(",
"c",
"Condition",
")",
"SetError",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"cond",
":=",
"amqp",
".",
"MakeError",
"(",
"err",
")",
"\n",
"c",
".",
"SetName",
"(",
"cond",
".",
"Name",
")",
"\n",
"c",
".",
"Se... | // Set a Go error into a condition, converting to an amqp.Error using amqp.MakeError | [
"Set",
"a",
"Go",
"error",
"into",
"a",
"condition",
"converting",
"to",
"an",
"amqp",
".",
"Error",
"using",
"amqp",
".",
"MakeError"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L383-L389 |
144,413 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | Head | func (t Transport) Head() unsafe.Pointer {
return unsafe.Pointer(C.pn_transport_head(t.pn))
} | go | func (t Transport) Head() unsafe.Pointer {
return unsafe.Pointer(C.pn_transport_head(t.pn))
} | [
"func",
"(",
"t",
"Transport",
")",
"Head",
"(",
")",
"unsafe",
".",
"Pointer",
"{",
"return",
"unsafe",
".",
"Pointer",
"(",
"C",
".",
"pn_transport_head",
"(",
"t",
".",
"pn",
")",
")",
"\n",
"}"
] | // Special treatment for Transport.Head, return value is unsafe.Pointer not string | [
"Special",
"treatment",
"for",
"Transport",
".",
"Head",
"return",
"value",
"is",
"unsafe",
".",
"Pointer",
"not",
"string"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L428-L430 |
144,414 | apache/qpid-proton | go/src/qpid.apache.org/proton/wrappers.go | Tail | func (t Transport) Tail() unsafe.Pointer {
return unsafe.Pointer(C.pn_transport_tail(t.pn))
} | go | func (t Transport) Tail() unsafe.Pointer {
return unsafe.Pointer(C.pn_transport_tail(t.pn))
} | [
"func",
"(",
"t",
"Transport",
")",
"Tail",
"(",
")",
"unsafe",
".",
"Pointer",
"{",
"return",
"unsafe",
".",
"Pointer",
"(",
"C",
".",
"pn_transport_tail",
"(",
"t",
".",
"pn",
")",
")",
"\n",
"}"
] | // Special treatment for Transport.Tail, return value is unsafe.Pointer not string | [
"Special",
"treatment",
"for",
"Transport",
".",
"Tail",
"return",
"value",
"is",
"unsafe",
".",
"Pointer",
"not",
"string"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/proton/wrappers.go#L433-L435 |
144,415 | apache/qpid-proton | go/src/qpid.apache.org/electron/session.go | newSession | func newSession(c *connection, es proton.Session, setting ...SessionOption) *session {
s := &session{
connection: c,
pSession: es,
}
s.endpoint.init(es.String())
for _, set := range setting {
set(s)
}
c.handler.sessions[s.pSession] = s
s.pSession.SetIncomingCapacity(s.incomingCapacity)
s.pSession.SetOut... | go | func newSession(c *connection, es proton.Session, setting ...SessionOption) *session {
s := &session{
connection: c,
pSession: es,
}
s.endpoint.init(es.String())
for _, set := range setting {
set(s)
}
c.handler.sessions[s.pSession] = s
s.pSession.SetIncomingCapacity(s.incomingCapacity)
s.pSession.SetOut... | [
"func",
"newSession",
"(",
"c",
"*",
"connection",
",",
"es",
"proton",
".",
"Session",
",",
"setting",
"...",
"SessionOption",
")",
"*",
"session",
"{",
"s",
":=",
"&",
"session",
"{",
"connection",
":",
"c",
",",
"pSession",
":",
"es",
",",
"}",
"\... | // in proton goroutine | [
"in",
"proton",
"goroutine"
] | 713c3aa0a2423b34ebffb8a2b2a43f0271966e4b | https://github.com/apache/qpid-proton/blob/713c3aa0a2423b34ebffb8a2b2a43f0271966e4b/go/src/qpid.apache.org/electron/session.go#L59-L73 |
144,416 | 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 |
144,417 | 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 |
144,418 | 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 |
144,419 | 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 |
144,420 | 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 |
144,421 | 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 |
144,422 | 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 |
144,423 | 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 |
144,424 | 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 |
144,425 | 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 |
144,426 | 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 |
144,427 | 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 |
144,428 | 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 |
144,429 | 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 |
144,430 | 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 |
144,431 | 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 |
144,432 | 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 |
144,433 | 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 |
144,434 | 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 |
144,435 | 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 |
144,436 | 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 |
144,437 | 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 |
144,438 | 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 |
144,439 | 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 |
144,440 | 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 |
144,441 | 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 |
144,442 | 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 |
144,443 | 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 |
144,444 | 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 |
144,445 | 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 |
144,446 | 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 |
144,447 | 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 |
144,448 | 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 |
144,449 | 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 |
144,450 | 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 |
144,451 | 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 |
144,452 | 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 |
144,453 | 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 |
144,454 | 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 |
144,455 | 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 |
144,456 | 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 |
144,457 | 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 |
144,458 | 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 |
144,459 | 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 |
144,460 | 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 |
144,461 | 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 |
144,462 | 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 |
144,463 | 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 |
144,464 | 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 |
144,465 | 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 |
144,466 | 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 |
144,467 | 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 |
144,468 | 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 |
144,469 | 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 |
144,470 | 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 |
144,471 | 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 |
144,472 | 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 |
144,473 | 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 |
144,474 | 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 |
144,475 | 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 |
144,476 | 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 |
144,477 | 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 |
144,478 | 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 |
144,479 | 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 |
144,480 | 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 |
144,481 | 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 |
144,482 | 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 |
144,483 | 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 |
144,484 | 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 |
144,485 | 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 |
144,486 | 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 |
144,487 | 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 |
144,488 | 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 |
144,489 | 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 |
144,490 | 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 |
144,491 | 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 |
144,492 | 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 |
144,493 | 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 |
144,494 | 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 |
144,495 | 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 |
144,496 | 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 |
144,497 | 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 |
144,498 | 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 |
144,499 | 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 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.