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",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"d",
".",
"child",
".",
"Query",
"(",
"q",
")",
"\n",
"}"
] |
// 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())
}
return r
}
|
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())
}
return r
}
|
[
"func",
"newReceiver",
"(",
"ls",
"linkSettings",
")",
"*",
"receiver",
"{",
"r",
":=",
"&",
"receiver",
"{",
"link",
":",
"link",
"{",
"linkSettings",
":",
"ls",
"}",
"}",
"\n",
"r",
".",
"endpoint",
".",
"init",
"(",
"r",
".",
"link",
".",
"pLink",
".",
"String",
"(",
")",
")",
"\n",
"if",
"r",
".",
"capacity",
"<",
"1",
"{",
"r",
".",
"capacity",
"=",
"1",
"\n",
"}",
"\n",
"r",
".",
"buffer",
"=",
"make",
"(",
"chan",
"ReceivedMessage",
",",
"r",
".",
"capacity",
")",
"\n",
"r",
".",
"handler",
"(",
")",
".",
"addLink",
"(",
"r",
".",
"pLink",
",",
"r",
")",
"\n",
"r",
".",
"link",
".",
"pLink",
".",
"Open",
"(",
")",
"\n",
"if",
"r",
".",
"prefetch",
"{",
"r",
".",
"flow",
"(",
"r",
".",
"maxFlow",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"r",
"\n",
"}"
] |
// 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",
"-",
"(",
"len",
"(",
"r",
".",
"buffer",
")",
"+",
"r",
".",
"pLink",
".",
"Credit",
"(",
")",
")",
"\n",
"max",
":=",
"r",
".",
"maxFlow",
"(",
")",
"\n",
"if",
"need",
">",
"max",
"{",
"need",
"=",
"max",
"\n",
"}",
"\n",
"r",
".",
"flow",
"(",
"need",
")",
"\n",
"}",
")",
"\n",
"}"
] |
// 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",
"(",
")",
")",
"}",
")",
"\n",
"}",
"\n",
"}"
] |
// 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.connection.mc.Decode(m, bytes)
}
if err != nil {
localClose(r.pLink, err)
return
}
r.pLink.Advance()
if r.pLink.Credit() < 0 {
localClose(r.pLink, fmt.Errorf("received message in excess of credit limit"))
} else {
// We never issue more credit than cap(buffer) so this will not block.
r.buffer <- ReceivedMessage{m, delivery, r}
}
}
}
|
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.connection.mc.Decode(m, bytes)
}
if err != nil {
localClose(r.pLink, err)
return
}
r.pLink.Advance()
if r.pLink.Credit() < 0 {
localClose(r.pLink, fmt.Errorf("received message in excess of credit limit"))
} else {
// We never issue more credit than cap(buffer) so this will not block.
r.buffer <- ReceivedMessage{m, delivery, r}
}
}
}
|
[
"func",
"(",
"r",
"*",
"receiver",
")",
"message",
"(",
"delivery",
"proton",
".",
"Delivery",
")",
"{",
"if",
"r",
".",
"pLink",
".",
"State",
"(",
")",
".",
"RemoteClosed",
"(",
")",
"{",
"localClose",
"(",
"r",
".",
"pLink",
",",
"r",
".",
"pLink",
".",
"RemoteCondition",
"(",
")",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"delivery",
".",
"HasMessage",
"(",
")",
"{",
"bytes",
",",
"err",
":=",
"delivery",
".",
"MessageBytes",
"(",
")",
"\n",
"var",
"m",
"amqp",
".",
"Message",
"\n",
"if",
"err",
"==",
"nil",
"{",
"m",
"=",
"amqp",
".",
"NewMessage",
"(",
")",
"\n",
"err",
"=",
"r",
".",
"session",
".",
"connection",
".",
"mc",
".",
"Decode",
"(",
"m",
",",
"bytes",
")",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"localClose",
"(",
"r",
".",
"pLink",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"r",
".",
"pLink",
".",
"Advance",
"(",
")",
"\n",
"if",
"r",
".",
"pLink",
".",
"Credit",
"(",
")",
"<",
"0",
"{",
"localClose",
"(",
"r",
".",
"pLink",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}",
"else",
"{",
"// We never issue more credit than cap(buffer) so this will not block.",
"r",
".",
"buffer",
"<-",
"ReceivedMessage",
"{",
"m",
",",
"delivery",
",",
"r",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// 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",
"(",
")",
"{",
"// Deliveries are valid as long as the connection is, unless settled.",
"rm",
".",
"pDelivery",
".",
"SettleAs",
"(",
"uint64",
"(",
"status",
")",
")",
"\n",
"}",
")",
"\n",
"}"
] |
// 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",
"(",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
// 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",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
".",
"Name",
"(",
")",
",",
"l",
".",
"Source",
"(",
")",
".",
"Address",
"(",
")",
",",
"l",
".",
"Target",
"(",
")",
".",
"Address",
"(",
")",
")",
"\n",
"default",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
".",
"Name",
"(",
")",
",",
"l",
".",
"Target",
"(",
")",
".",
"Address",
"(",
")",
",",
"l",
".",
"Source",
"(",
")",
".",
"Address",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] |
// 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",
".",
"Name",
"(",
")",
",",
"Description",
":",
"c",
".",
"Description",
"(",
")",
"}",
"\n",
"}"
] |
// 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",
".",
"SetDescription",
"(",
"cond",
".",
"Description",
")",
"\n",
"}",
"\n",
"}"
] |
// 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.SetOutgoingWindow(s.outgoingWindow)
s.pSession.Open()
return s
}
|
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.SetOutgoingWindow(s.outgoingWindow)
s.pSession.Open()
return s
}
|
[
"func",
"newSession",
"(",
"c",
"*",
"connection",
",",
"es",
"proton",
".",
"Session",
",",
"setting",
"...",
"SessionOption",
")",
"*",
"session",
"{",
"s",
":=",
"&",
"session",
"{",
"connection",
":",
"c",
",",
"pSession",
":",
"es",
",",
"}",
"\n",
"s",
".",
"endpoint",
".",
"init",
"(",
"es",
".",
"String",
"(",
")",
")",
"\n",
"for",
"_",
",",
"set",
":=",
"range",
"setting",
"{",
"set",
"(",
"s",
")",
"\n",
"}",
"\n",
"c",
".",
"handler",
".",
"sessions",
"[",
"s",
".",
"pSession",
"]",
"=",
"s",
"\n",
"s",
".",
"pSession",
".",
"SetIncomingCapacity",
"(",
"s",
".",
"incomingCapacity",
")",
"\n",
"s",
".",
"pSession",
".",
"SetOutgoingWindow",
"(",
"s",
".",
"outgoingWindow",
")",
"\n",
"s",
".",
"pSession",
".",
"Open",
"(",
")",
"\n",
"return",
"s",
"\n",
"}"
] |
// 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",
",",
"IncomingCapacity",
"(",
"in",
".",
"incomingCapacity",
")",
",",
"OutgoingWindow",
"(",
"in",
".",
"outgoingWindow",
")",
")",
"\n",
"}",
")",
"\n",
"}"
] |
// 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
}
} else if strings.IndexByte(hostport, ':') < 0 {
return hostport, "", nil
}
return net.SplitHostPort(hostport)
}
|
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
}
} else if strings.IndexByte(hostport, ':') < 0 {
return hostport, "", nil
}
return net.SplitHostPort(hostport)
}
|
[
"func",
"splitHostPort",
"(",
"hostport",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"if",
"hostport",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n",
"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",
"\n",
"}",
"\n",
"}",
"else",
"if",
"strings",
".",
"IndexByte",
"(",
"hostport",
",",
"':'",
")",
"<",
"0",
"{",
"return",
"hostport",
",",
"\"",
"\"",
",",
"nil",
"\n",
"}",
"\n",
"return",
"net",
".",
"SplitHostPort",
"(",
"hostport",
")",
"\n",
"}"
] |
// 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",
"{",
"m",
":=",
"amqp",
".",
"NewMessage",
"(",
")",
"\n",
"err",
"=",
"m",
".",
"Decode",
"(",
"bytes",
")",
"\n",
"return",
"m",
",",
"err",
"\n",
"}",
"\n",
"return",
"nil",
",",
"err",
"\n",
"}"
] |
// 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",
"always",
"a",
"safe",
"context",
"to",
"call",
"this",
"function",
".",
"Will",
"return",
"an",
"error",
"if",
"message",
"is",
"incomplete",
"or",
"not",
"current",
"."
] |
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 != len(data) {
return nil, fmt.Errorf("cannot receive message: %s", PnErrorCode(result))
}
return data, nil
}
|
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 != len(data) {
return nil, fmt.Errorf("cannot receive message: %s", PnErrorCode(result))
}
return data, nil
}
|
[
"func",
"(",
"delivery",
"Delivery",
")",
"MessageBytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"!",
"delivery",
".",
"Readable",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"delivery",
".",
"Partial",
"(",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"data",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"delivery",
".",
"Pending",
"(",
")",
")",
"\n",
"result",
":=",
"delivery",
".",
"Link",
"(",
")",
".",
"Recv",
"(",
"data",
")",
"\n",
"if",
"result",
"!=",
"len",
"(",
"data",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"PnErrorCode",
"(",
"result",
")",
")",
"\n",
"}",
"\n",
"return",
"data",
",",
"nil",
"\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",
"event",
"is",
"always",
"a",
"safe",
"context",
"to",
"call",
"this",
"function",
".",
"Will",
"return",
"an",
"error",
"if",
"message",
"is",
"incomplete",
"or",
"not",
"current",
"."
] |
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",
"{",
"}",
",",
"err",
"\n",
"}",
"\n",
"d",
",",
"err",
":=",
"link",
".",
"SendMessageBytes",
"(",
"bytes",
")",
"\n",
"return",
"d",
",",
"err",
"\n",
"}"
] |
// 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 delivery, fmt.Errorf("send failed %v", PnErrorCode(result))
} else {
return delivery, fmt.Errorf("send incomplete %v of %v", result, len(bytes))
}
}
if link.RemoteSndSettleMode() == SndSettled {
delivery.Settle()
}
return delivery, nil
}
|
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 delivery, fmt.Errorf("send failed %v", PnErrorCode(result))
} else {
return delivery, fmt.Errorf("send incomplete %v of %v", result, len(bytes))
}
}
if link.RemoteSndSettleMode() == SndSettled {
delivery.Settle()
}
return delivery, nil
}
|
[
"func",
"(",
"link",
"Link",
")",
"SendMessageBytes",
"(",
"bytes",
"[",
"]",
"byte",
")",
"(",
"Delivery",
",",
"error",
")",
"{",
"if",
"!",
"link",
".",
"IsSender",
"(",
")",
"{",
"return",
"Delivery",
"{",
"}",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"delivery",
":=",
"link",
".",
"Delivery",
"(",
"nextTag",
"(",
")",
")",
"\n",
"result",
":=",
"link",
".",
"SendBytes",
"(",
"bytes",
")",
"\n",
"link",
".",
"Advance",
"(",
")",
"\n",
"if",
"result",
"!=",
"len",
"(",
"bytes",
")",
"{",
"if",
"result",
"<",
"0",
"{",
"return",
"delivery",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"PnErrorCode",
"(",
"result",
")",
")",
"\n",
"}",
"else",
"{",
"return",
"delivery",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"result",
",",
"len",
"(",
"bytes",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"link",
".",
"RemoteSndSettleMode",
"(",
")",
"==",
"SndSettled",
"{",
"delivery",
".",
"Settle",
"(",
")",
"\n",
"}",
"\n",
"return",
"delivery",
",",
"nil",
"\n",
"}"
] |
// 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",
"}",
"\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",
"(",
")",
"\n",
"done",
"<-",
"ep",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"<-",
"done",
"\n",
"}"
] |
// 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",
"=",
"mc",
".",
"Decode",
"(",
"m",
",",
"bytes",
")",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
// 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 < 0:
return buf, fmt.Errorf("cannot encode message: %s", PnErrorCode(result))
default:
return buf[:len], nil
}
}
return encodeGrow(buffer, encode)
}
|
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 < 0:
return buf, fmt.Errorf("cannot encode message: %s", PnErrorCode(result))
default:
return buf[:len], nil
}
}
return encodeGrow(buffer, encode)
}
|
[
"func",
"(",
"mc",
"*",
"MessageCodec",
")",
"Encode",
"(",
"m",
"Message",
",",
"buffer",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pn",
":=",
"mc",
".",
"pnMessage",
"(",
")",
"\n",
"m",
".",
"(",
"*",
"message",
")",
".",
"put",
"(",
"pn",
")",
"\n",
"encode",
":=",
"func",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"len",
":=",
"cLen",
"(",
"buf",
")",
"\n",
"result",
":=",
"C",
".",
"pn_message_encode",
"(",
"pn",
",",
"cPtr",
"(",
"buf",
")",
",",
"&",
"len",
")",
"\n",
"switch",
"{",
"case",
"result",
"==",
"C",
".",
"PN_OVERFLOW",
":",
"return",
"buf",
",",
"overflow",
"\n",
"case",
"result",
"<",
"0",
":",
"return",
"buf",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"PnErrorCode",
"(",
"result",
")",
")",
"\n",
"default",
":",
"return",
"buf",
"[",
":",
"len",
"]",
",",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"encodeGrow",
"(",
"buffer",
",",
"encode",
")",
"\n",
"}"
] |
// 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("first-acquirer", m.firstAcquirer, isZero)
b.field("delivery-count", m.deliveryCount, isZero)
b.field("message-id", m.messageId, isNil)
b.field("user-id", m.userId, isEmpty)
b.field("subject", m.subject, isEmpty)
b.field("reply-to", m.replyTo, isEmpty)
b.field("correlation-id", m.correlationId, isNil)
b.field("content-type", m.contentType, isEmpty)
b.field("content-encoding", m.contentEncoding, isEmpty)
b.field("expiry-time", m.expiryTime, isZero)
b.field("creation-time", m.creationTime, isZero)
b.field("group-id", m.groupId, isEmpty)
b.field("group-sequence", m.groupSequence, isZero)
b.field("reply-to-group-id", m.replyToGroupId, isEmpty)
b.field("inferred", m.inferred, isZero)
b.field("delivery-annotations", m.deliveryAnnotations, isEmpty)
b.field("message-annotations", m.messageAnnotations, isEmpty)
b.field("application-properties", m.applicationProperties, isEmpty)
b.field("body", m.body, isNil)
b.WriteString("}")
return b.String()
}
|
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("first-acquirer", m.firstAcquirer, isZero)
b.field("delivery-count", m.deliveryCount, isZero)
b.field("message-id", m.messageId, isNil)
b.field("user-id", m.userId, isEmpty)
b.field("subject", m.subject, isEmpty)
b.field("reply-to", m.replyTo, isEmpty)
b.field("correlation-id", m.correlationId, isNil)
b.field("content-type", m.contentType, isEmpty)
b.field("content-encoding", m.contentEncoding, isEmpty)
b.field("expiry-time", m.expiryTime, isZero)
b.field("creation-time", m.creationTime, isZero)
b.field("group-id", m.groupId, isEmpty)
b.field("group-sequence", m.groupSequence, isZero)
b.field("reply-to-group-id", m.replyToGroupId, isEmpty)
b.field("inferred", m.inferred, isZero)
b.field("delivery-annotations", m.deliveryAnnotations, isEmpty)
b.field("message-annotations", m.messageAnnotations, isEmpty)
b.field("application-properties", m.applicationProperties, isEmpty)
b.field("body", m.body, isNil)
b.WriteString("}")
return b.String()
}
|
[
"func",
"(",
"m",
"*",
"message",
")",
"String",
"(",
")",
"string",
"{",
"var",
"b",
"stringBuilder",
"\n",
"b",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"address",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"durable",
",",
"isZero",
")",
"\n",
"// Priority has weird default",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"priority",
",",
"func",
"(",
"v",
"interface",
"{",
"}",
")",
"bool",
"{",
"return",
"v",
".",
"(",
"uint8",
")",
"==",
"4",
"}",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"ttl",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"firstAcquirer",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"deliveryCount",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"messageId",
",",
"isNil",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"userId",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"subject",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"replyTo",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"correlationId",
",",
"isNil",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"contentType",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"contentEncoding",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"expiryTime",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"creationTime",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"groupId",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"groupSequence",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"replyToGroupId",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"inferred",
",",
"isZero",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"deliveryAnnotations",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"messageAnnotations",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"applicationProperties",
",",
"isEmpty",
")",
"\n",
"b",
".",
"field",
"(",
"\"",
"\"",
",",
"m",
".",
"body",
",",
"isNil",
")",
"\n",
"b",
".",
"WriteString",
"(",
"\"",
"\"",
")",
"\n",
"return",
"b",
".",
"String",
"(",
")",
"\n",
"}"
] |
// 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",
"}",
"\n",
"out",
"=",
"make",
"(",
"map",
"[",
"AnnotationKey",
"]",
"interface",
"{",
"}",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"in",
"{",
"out",
"[",
"AnnotationKeyString",
"(",
"k",
")",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"\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",
"for",
"k",
",",
"v",
":=",
"range",
"m",
"{",
"fmt",
".",
"Fprintf",
"(",
"out",
",",
"\"",
"\"",
",",
"k",
",",
"k",
",",
"v",
",",
"v",
")",
"\n",
"i",
"--",
"\n",
"if",
"i",
">",
"0",
"{",
"fmt",
".",
"Fprint",
"(",
"out",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"fmt",
".",
"Fprint",
"(",
"out",
",",
"\"",
"\"",
")",
"\n",
"return",
"out",
".",
"String",
"(",
")",
"\n",
"}"
] |
// 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",
"<",
"len",
"(",
"l",
")",
";",
"i",
"++",
"{",
"fmt",
".",
"Fprintf",
"(",
"out",
",",
"\"",
"\"",
",",
"l",
"[",
"i",
"]",
",",
"l",
"[",
"i",
"]",
")",
"\n",
"if",
"i",
"==",
"len",
"(",
"l",
")",
"-",
"1",
"{",
"fmt",
".",
"Fprint",
"(",
"out",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"fmt",
".",
"Fprint",
"(",
"out",
",",
"\"",
"\"",
")",
"\n",
"return",
"out",
".",
"String",
"(",
")",
"\n",
"}"
] |
// 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",
".",
"UnixNano",
"(",
")",
"/",
"int64",
"(",
"time",
".",
"Millisecond",
")",
")",
"\n",
"}"
] |
// 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",
")",
"*",
"int64",
"(",
"time",
".",
"Millisecond",
")",
")",
"\n",
"}"
] |
// 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 := b.container.Accept(listener)
if err != nil {
debugf("Accept error: %v", err)
continue
}
cc := &connection{b, c}
go cc.run() // Handle the connection
debugf("Accepted %v", c)
}
}
|
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 := b.container.Accept(listener)
if err != nil {
debugf("Accept error: %v", err)
continue
}
cc := &connection{b, c}
go cc.run() // Handle the connection
debugf("Accepted %v", c)
}
}
|
[
"func",
"(",
"b",
"*",
"broker",
")",
"run",
"(",
")",
"error",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"*",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"listener",
".",
"Close",
"(",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"listener",
".",
"Addr",
"(",
")",
")",
"\n\n",
"go",
"b",
".",
"acknowledgements",
"(",
")",
"// Handles acknowledgements for all connections.",
"\n\n",
"// Start a goroutine for each new connections",
"for",
"{",
"c",
",",
"err",
":=",
"b",
".",
"container",
".",
"Accept",
"(",
"listener",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"debugf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"cc",
":=",
"&",
"connection",
"{",
"b",
",",
"c",
"}",
"\n",
"go",
"cc",
".",
"run",
"(",
")",
"// Handle the connection",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"c",
")",
"\n",
"}",
"\n",
"}"
] |
// 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",
",",
"err",
":=",
"receiver",
".",
"Receive",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"debugf",
"(",
"\"",
"\"",
",",
"receiver",
",",
"rm",
".",
"Message",
".",
"Body",
"(",
")",
")",
"\n",
"q",
"<-",
"rm",
".",
"Message",
"\n",
"rm",
".",
"Accept",
"(",
")",
"\n",
"}",
"else",
"{",
"debugf",
"(",
"\"",
"\"",
",",
"receiver",
",",
"err",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// 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 // Record sent message
sender.SendAsync(m, c.broker.acks, sm) // Receive outcome on c.broker.acks with Value sm
case <-sender.Done(): // break if sender is closed
break
}
}
}
|
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 // Record sent message
sender.SendAsync(m, c.broker.acks, sm) // Receive outcome on c.broker.acks with Value sm
case <-sender.Done(): // break if sender is closed
break
}
}
}
|
[
"func",
"(",
"c",
"*",
"connection",
")",
"sender",
"(",
"sender",
"electron",
".",
"Sender",
")",
"{",
"q",
":=",
"c",
".",
"broker",
".",
"queues",
".",
"Get",
"(",
"sender",
".",
"Source",
"(",
")",
")",
"\n",
"for",
"{",
"if",
"sender",
".",
"Error",
"(",
")",
"!=",
"nil",
"{",
"debugf",
"(",
"\"",
"\"",
",",
"sender",
",",
"sender",
".",
"Error",
"(",
")",
")",
"\n",
"return",
"\n",
"}",
"\n",
"select",
"{",
"case",
"m",
":=",
"<-",
"q",
":",
"debugf",
"(",
"\"",
"\"",
",",
"sender",
",",
"m",
".",
"Body",
"(",
")",
")",
"\n",
"sm",
":=",
"sentMessage",
"{",
"m",
",",
"q",
"}",
"\n",
"c",
".",
"broker",
".",
"sent",
"<-",
"sm",
"// Record sent message",
"\n",
"sender",
".",
"SendAsync",
"(",
"m",
",",
"c",
".",
"broker",
".",
"acks",
",",
"sm",
")",
"// Receive outcome on c.broker.acks with Value sm",
"\n\n",
"case",
"<-",
"sender",
".",
"Done",
"(",
")",
":",
"// break if sender is closed",
"break",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// 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 := outcome.Value.(sentMessage)
delete(sentMap, sm)
if outcome.Status != electron.Accepted { // Error, release or rejection
sm.q.PutBack(sm.m) // Put the message back on the queue.
debugf("message %v put back, status %v, error %v", sm.m.Body(), outcome.Status, outcome.Error)
}
}
}
}
|
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 := outcome.Value.(sentMessage)
delete(sentMap, sm)
if outcome.Status != electron.Accepted { // Error, release or rejection
sm.q.PutBack(sm.m) // Put the message back on the queue.
debugf("message %v put back, status %v, error %v", sm.m.Body(), outcome.Status, outcome.Error)
}
}
}
}
|
[
"func",
"(",
"b",
"*",
"broker",
")",
"acknowledgements",
"(",
")",
"{",
"sentMap",
":=",
"make",
"(",
"map",
"[",
"sentMessage",
"]",
"bool",
")",
"\n",
"for",
"{",
"select",
"{",
"case",
"sm",
",",
"ok",
":=",
"<-",
"b",
".",
"sent",
":",
"// A local sender records that it has sent a message.",
"if",
"ok",
"{",
"sentMap",
"[",
"sm",
"]",
"=",
"true",
"\n",
"}",
"else",
"{",
"return",
"// Closed",
"\n",
"}",
"\n",
"case",
"outcome",
":=",
"<-",
"b",
".",
"acks",
":",
"// The message outcome is available",
"sm",
":=",
"outcome",
".",
"Value",
".",
"(",
"sentMessage",
")",
"\n",
"delete",
"(",
"sentMap",
",",
"sm",
")",
"\n",
"if",
"outcome",
".",
"Status",
"!=",
"electron",
".",
"Accepted",
"{",
"// Error, release or rejection",
"sm",
".",
"q",
".",
"PutBack",
"(",
"sm",
".",
"m",
")",
"// Put the message back on the queue.",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"sm",
".",
"m",
".",
"Body",
"(",
")",
",",
"outcome",
".",
"Status",
",",
"outcome",
".",
"Error",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// 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",
"outcomes",
"are",
"returned",
"via",
"channels",
"defined",
"by",
"the",
"user",
"so",
"they",
"can",
"be",
"grouped",
"in",
"any",
"way",
"that",
"suits",
"the",
"application",
"."
] |
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",
"<-",
"m",
"}",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
// 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",
"]",
"\n",
"if",
"q",
"==",
"nil",
"{",
"q",
"=",
"make",
"(",
"queue",
",",
"qs",
".",
"queueSize",
")",
"\n",
"qs",
".",
"m",
"[",
"name",
"]",
"=",
"q",
"\n",
"}",
"\n",
"return",
"q",
"\n",
"}"
] |
// 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",
".",
"Sets",
"SndSettleMode",
"=",
"SendSettled",
"and",
"RcvSettleMode",
"=",
"RcvFirst"
] |
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=SndUnsettled and RcvSettleMode=RcvFirst
|
[
"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",
"=",
"SndUnsettled",
"and",
"RcvSettleMode",
"=",
"RcvFirst"
] |
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()
}
if l.IsSender() {
l.pLink = l.session.pSession.Sender(l.linkName)
} else {
l.pLink = l.session.pSession.Receiver(l.linkName)
}
if l.pLink.IsNil() {
return l, fmt.Errorf("cannot create link %s", l.pLink)
}
l.pLink.Source().SetAddress(l.source)
if len(l.filter) > 0 {
if err := l.pLink.Source().Filter().Marshal(l.filter); err != nil {
panic(err) // Shouldn't happen
}
}
l.pLink.Source().SetDurability(l.sourceSettings.Durability)
l.pLink.Source().SetExpiryPolicy(l.sourceSettings.Expiry)
l.pLink.Source().SetTimeout(l.sourceSettings.Timeout)
l.pLink.Source().SetDynamic(l.sourceSettings.Dynamic)
l.pLink.Target().SetAddress(l.target)
l.pLink.Target().SetDurability(l.targetSettings.Durability)
l.pLink.Target().SetExpiryPolicy(l.targetSettings.Expiry)
l.pLink.Target().SetTimeout(l.targetSettings.Timeout)
l.pLink.Target().SetDynamic(l.targetSettings.Dynamic)
l.pLink.SetSndSettleMode(proton.SndSettleMode(l.sndSettle))
l.pLink.SetRcvSettleMode(proton.RcvSettleMode(l.rcvSettle))
l.pLink.Open()
return l, nil
}
|
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()
}
if l.IsSender() {
l.pLink = l.session.pSession.Sender(l.linkName)
} else {
l.pLink = l.session.pSession.Receiver(l.linkName)
}
if l.pLink.IsNil() {
return l, fmt.Errorf("cannot create link %s", l.pLink)
}
l.pLink.Source().SetAddress(l.source)
if len(l.filter) > 0 {
if err := l.pLink.Source().Filter().Marshal(l.filter); err != nil {
panic(err) // Shouldn't happen
}
}
l.pLink.Source().SetDurability(l.sourceSettings.Durability)
l.pLink.Source().SetExpiryPolicy(l.sourceSettings.Expiry)
l.pLink.Source().SetTimeout(l.sourceSettings.Timeout)
l.pLink.Source().SetDynamic(l.sourceSettings.Dynamic)
l.pLink.Target().SetAddress(l.target)
l.pLink.Target().SetDurability(l.targetSettings.Durability)
l.pLink.Target().SetExpiryPolicy(l.targetSettings.Expiry)
l.pLink.Target().SetTimeout(l.targetSettings.Timeout)
l.pLink.Target().SetDynamic(l.targetSettings.Dynamic)
l.pLink.SetSndSettleMode(proton.SndSettleMode(l.sndSettle))
l.pLink.SetRcvSettleMode(proton.RcvSettleMode(l.rcvSettle))
l.pLink.Open()
return l, nil
}
|
[
"func",
"makeLocalLink",
"(",
"sn",
"*",
"session",
",",
"isSender",
"bool",
",",
"setting",
"...",
"LinkOption",
")",
"(",
"linkSettings",
",",
"error",
")",
"{",
"l",
":=",
"linkSettings",
"{",
"isSender",
":",
"isSender",
",",
"capacity",
":",
"1",
",",
"prefetch",
":",
"false",
",",
"session",
":",
"sn",
",",
"}",
"\n",
"for",
"_",
",",
"set",
":=",
"range",
"setting",
"{",
"set",
"(",
"&",
"l",
")",
"\n",
"}",
"\n",
"if",
"l",
".",
"linkName",
"==",
"\"",
"\"",
"{",
"l",
".",
"linkName",
"=",
"l",
".",
"session",
".",
"connection",
".",
"container",
".",
"nextLinkName",
"(",
")",
"\n",
"}",
"\n",
"if",
"l",
".",
"IsSender",
"(",
")",
"{",
"l",
".",
"pLink",
"=",
"l",
".",
"session",
".",
"pSession",
".",
"Sender",
"(",
"l",
".",
"linkName",
")",
"\n",
"}",
"else",
"{",
"l",
".",
"pLink",
"=",
"l",
".",
"session",
".",
"pSession",
".",
"Receiver",
"(",
"l",
".",
"linkName",
")",
"\n",
"}",
"\n",
"if",
"l",
".",
"pLink",
".",
"IsNil",
"(",
")",
"{",
"return",
"l",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"l",
".",
"pLink",
")",
"\n",
"}",
"\n",
"l",
".",
"pLink",
".",
"Source",
"(",
")",
".",
"SetAddress",
"(",
"l",
".",
"source",
")",
"\n\n",
"if",
"len",
"(",
"l",
".",
"filter",
")",
">",
"0",
"{",
"if",
"err",
":=",
"l",
".",
"pLink",
".",
"Source",
"(",
")",
".",
"Filter",
"(",
")",
".",
"Marshal",
"(",
"l",
".",
"filter",
")",
";",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"// Shouldn't happen",
"\n",
"}",
"\n",
"}",
"\n",
"l",
".",
"pLink",
".",
"Source",
"(",
")",
".",
"SetDurability",
"(",
"l",
".",
"sourceSettings",
".",
"Durability",
")",
"\n",
"l",
".",
"pLink",
".",
"Source",
"(",
")",
".",
"SetExpiryPolicy",
"(",
"l",
".",
"sourceSettings",
".",
"Expiry",
")",
"\n",
"l",
".",
"pLink",
".",
"Source",
"(",
")",
".",
"SetTimeout",
"(",
"l",
".",
"sourceSettings",
".",
"Timeout",
")",
"\n",
"l",
".",
"pLink",
".",
"Source",
"(",
")",
".",
"SetDynamic",
"(",
"l",
".",
"sourceSettings",
".",
"Dynamic",
")",
"\n\n",
"l",
".",
"pLink",
".",
"Target",
"(",
")",
".",
"SetAddress",
"(",
"l",
".",
"target",
")",
"\n",
"l",
".",
"pLink",
".",
"Target",
"(",
")",
".",
"SetDurability",
"(",
"l",
".",
"targetSettings",
".",
"Durability",
")",
"\n",
"l",
".",
"pLink",
".",
"Target",
"(",
")",
".",
"SetExpiryPolicy",
"(",
"l",
".",
"targetSettings",
".",
"Expiry",
")",
"\n",
"l",
".",
"pLink",
".",
"Target",
"(",
")",
".",
"SetTimeout",
"(",
"l",
".",
"targetSettings",
".",
"Timeout",
")",
"\n",
"l",
".",
"pLink",
".",
"Target",
"(",
")",
".",
"SetDynamic",
"(",
"l",
".",
"targetSettings",
".",
"Dynamic",
")",
"\n\n",
"l",
".",
"pLink",
".",
"SetSndSettleMode",
"(",
"proton",
".",
"SndSettleMode",
"(",
"l",
".",
"sndSettle",
")",
")",
"\n",
"l",
".",
"pLink",
".",
"SetRcvSettleMode",
"(",
"proton",
".",
"RcvSettleMode",
"(",
"l",
".",
"rcvSettle",
")",
")",
"\n",
"l",
".",
"pLink",
".",
"Open",
"(",
")",
"\n",
"return",
"l",
",",
"nil",
"\n",
"}"
] |
// 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",
"(",
")",
"!=",
"nil",
"{",
"return",
"l",
".",
"Error",
"(",
")",
"\n",
"}",
"\n",
"credit",
"=",
"l",
".",
"pLink",
".",
"Credit",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}",
")",
"\n",
"return",
"\n",
"}"
] |
// 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",
"(",
"enums",
",",
"enumType",
"{",
"enum",
"[",
"2",
"]",
",",
"enumValRe",
".",
"FindAllString",
"(",
"enum",
"[",
"1",
"]",
",",
"-",
"1",
")",
"}",
")",
"\n",
"}",
"\n",
"return",
"enums",
"\n",
"}"
] |
// 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, newEventType(e))
}
}
doTemplate(out, etypes, `
type EventType int
const ({{range .}}
E{{.Name}} EventType = C.{{.Cname}}{{end}}
)
`)
doTemplate(out, etypes, `
func (e EventType) String() string {
switch e {
{{range .}}
case C.{{.Cname}}: return "{{.Name}}"{{end}}
}
return "Unknown"
}
`)
}
|
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, newEventType(e))
}
}
doTemplate(out, etypes, `
type EventType int
const ({{range .}}
E{{.Name}} EventType = C.{{.Cname}}{{end}}
)
`)
doTemplate(out, etypes, `
func (e EventType) String() string {
switch e {
{{range .}}
case C.{{.Cname}}: return "{{.Name}}"{{end}}
}
return "Unknown"
}
`)
}
|
[
"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",
"enums",
":=",
"findEnums",
"(",
"event_h",
")",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"enums",
"[",
"0",
"]",
".",
"Values",
"{",
"if",
"skipEventRe",
".",
"FindStringSubmatch",
"(",
"e",
")",
"==",
"nil",
"{",
"etypes",
"=",
"append",
"(",
"etypes",
",",
"newEventType",
"(",
"e",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"doTemplate",
"(",
"out",
",",
"etypes",
",",
"`\ntype EventType int\nconst ({{range .}}\n\t E{{.Name}} EventType = C.{{.Cname}}{{end}}\n)\n`",
")",
"\n\n",
"doTemplate",
"(",
"out",
",",
"etypes",
",",
"`\nfunc (e EventType) String() string {\n\tswitch e {\n{{range .}}\n\tcase C.{{.Cname}}: return \"{{.Name}}\"{{end}}\n\t}\n\treturn \"Unknown\"\n}\n`",
")",
"\n",
"}"
] |
// 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",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"mixedCaseTrim",
"(",
"fname",
",",
"\"",
"\"",
")",
"\n",
"}"
] |
// 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.NewMessagingAdapter(newHandler(&b.queues))
// We want to accept messages when they are enqueued, not just when they
// are received, so we turn off auto-accept and prefetch by the adapter.
adapter.Prefetch = 0
adapter.AutoAccept = false
engine, err := proton.NewEngine(conn, adapter)
if err != nil {
debugf("Connection error: %v", err)
continue
}
engine.Server() // Enable server-side protocol negotiation.
debugf("Accepted connection %s", engine)
go func() { // Start goroutine to run the engine event loop
engine.Run()
debugf("Closed %s", engine)
}()
}
}
|
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.NewMessagingAdapter(newHandler(&b.queues))
// We want to accept messages when they are enqueued, not just when they
// are received, so we turn off auto-accept and prefetch by the adapter.
adapter.Prefetch = 0
adapter.AutoAccept = false
engine, err := proton.NewEngine(conn, adapter)
if err != nil {
debugf("Connection error: %v", err)
continue
}
engine.Server() // Enable server-side protocol negotiation.
debugf("Accepted connection %s", engine)
go func() { // Start goroutine to run the engine event loop
engine.Run()
debugf("Closed %s", engine)
}()
}
}
|
[
"func",
"(",
"b",
"*",
"broker",
")",
"run",
"(",
")",
"error",
"{",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"*",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"listener",
".",
"Close",
"(",
")",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"listener",
".",
"Addr",
"(",
")",
")",
"\n",
"for",
"{",
"conn",
",",
"err",
":=",
"listener",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"debugf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"adapter",
":=",
"proton",
".",
"NewMessagingAdapter",
"(",
"newHandler",
"(",
"&",
"b",
".",
"queues",
")",
")",
"\n",
"// We want to accept messages when they are enqueued, not just when they",
"// are received, so we turn off auto-accept and prefetch by the adapter.",
"adapter",
".",
"Prefetch",
"=",
"0",
"\n",
"adapter",
".",
"AutoAccept",
"=",
"false",
"\n",
"engine",
",",
"err",
":=",
"proton",
".",
"NewEngine",
"(",
"conn",
",",
"adapter",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"debugf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"continue",
"\n",
"}",
"\n",
"engine",
".",
"Server",
"(",
")",
"// Enable server-side protocol negotiation.",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"engine",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"// Start goroutine to run the engine event loop",
"engine",
".",
"Run",
"(",
")",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"engine",
")",
"\n",
"}",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
// 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().RemoteCondition().Error())
case proton.MSendable:
if s, ok := h.senders[e.Link()]; ok {
s.sendable() // Signal the send goroutine that we have credit.
} else {
proton.CloseError(e.Link(), amqp.Errorf(amqp.NotFound, "link %s sender not found", e.Link()))
}
case proton.MMessage:
m, err := e.Delivery().Message() // Message() must be called while handling the MMessage event.
if err != nil {
proton.CloseError(e.Link(), err)
break
}
r, ok := h.receivers[e.Link()]
if !ok {
proton.CloseError(e.Link(), amqp.Errorf(amqp.NotFound, "link %s receiver not found", e.Link()))
break
}
// This will not block as AMQP credit is set to the buffer capacity.
r.buffer <- receivedMessage{e.Delivery(), m}
debugf("link %s received %#v", e.Link(), m)
case proton.MConnectionClosed, proton.MDisconnected:
for l, _ := range h.receivers {
h.linkClosed(l, nil)
}
for l, _ := range h.senders {
h.linkClosed(l, nil)
}
}
}
|
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().RemoteCondition().Error())
case proton.MSendable:
if s, ok := h.senders[e.Link()]; ok {
s.sendable() // Signal the send goroutine that we have credit.
} else {
proton.CloseError(e.Link(), amqp.Errorf(amqp.NotFound, "link %s sender not found", e.Link()))
}
case proton.MMessage:
m, err := e.Delivery().Message() // Message() must be called while handling the MMessage event.
if err != nil {
proton.CloseError(e.Link(), err)
break
}
r, ok := h.receivers[e.Link()]
if !ok {
proton.CloseError(e.Link(), amqp.Errorf(amqp.NotFound, "link %s receiver not found", e.Link()))
break
}
// This will not block as AMQP credit is set to the buffer capacity.
r.buffer <- receivedMessage{e.Delivery(), m}
debugf("link %s received %#v", e.Link(), m)
case proton.MConnectionClosed, proton.MDisconnected:
for l, _ := range h.receivers {
h.linkClosed(l, nil)
}
for l, _ := range h.senders {
h.linkClosed(l, nil)
}
}
}
|
[
"func",
"(",
"h",
"*",
"handler",
")",
"HandleMessagingEvent",
"(",
"t",
"proton",
".",
"MessagingEvent",
",",
"e",
"proton",
".",
"Event",
")",
"{",
"switch",
"t",
"{",
"case",
"proton",
".",
"MStart",
":",
"h",
".",
"injecter",
"=",
"e",
".",
"Injecter",
"(",
")",
"\n\n",
"case",
"proton",
".",
"MLinkOpening",
":",
"if",
"e",
".",
"Link",
"(",
")",
".",
"IsReceiver",
"(",
")",
"{",
"h",
".",
"startReceiver",
"(",
"e",
")",
"\n",
"}",
"else",
"{",
"h",
".",
"startSender",
"(",
"e",
")",
"\n",
"}",
"\n\n",
"case",
"proton",
".",
"MLinkClosed",
":",
"h",
".",
"linkClosed",
"(",
"e",
".",
"Link",
"(",
")",
",",
"e",
".",
"Link",
"(",
")",
".",
"RemoteCondition",
"(",
")",
".",
"Error",
"(",
")",
")",
"\n\n",
"case",
"proton",
".",
"MSendable",
":",
"if",
"s",
",",
"ok",
":=",
"h",
".",
"senders",
"[",
"e",
".",
"Link",
"(",
")",
"]",
";",
"ok",
"{",
"s",
".",
"sendable",
"(",
")",
"// Signal the send goroutine that we have credit.",
"\n",
"}",
"else",
"{",
"proton",
".",
"CloseError",
"(",
"e",
".",
"Link",
"(",
")",
",",
"amqp",
".",
"Errorf",
"(",
"amqp",
".",
"NotFound",
",",
"\"",
"\"",
",",
"e",
".",
"Link",
"(",
")",
")",
")",
"\n",
"}",
"\n\n",
"case",
"proton",
".",
"MMessage",
":",
"m",
",",
"err",
":=",
"e",
".",
"Delivery",
"(",
")",
".",
"Message",
"(",
")",
"// Message() must be called while handling the MMessage event.",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"proton",
".",
"CloseError",
"(",
"e",
".",
"Link",
"(",
")",
",",
"err",
")",
"\n",
"break",
"\n",
"}",
"\n",
"r",
",",
"ok",
":=",
"h",
".",
"receivers",
"[",
"e",
".",
"Link",
"(",
")",
"]",
"\n",
"if",
"!",
"ok",
"{",
"proton",
".",
"CloseError",
"(",
"e",
".",
"Link",
"(",
")",
",",
"amqp",
".",
"Errorf",
"(",
"amqp",
".",
"NotFound",
",",
"\"",
"\"",
",",
"e",
".",
"Link",
"(",
")",
")",
")",
"\n",
"break",
"\n",
"}",
"\n",
"// This will not block as AMQP credit is set to the buffer capacity.",
"r",
".",
"buffer",
"<-",
"receivedMessage",
"{",
"e",
".",
"Delivery",
"(",
")",
",",
"m",
"}",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"e",
".",
"Link",
"(",
")",
",",
"m",
")",
"\n\n",
"case",
"proton",
".",
"MConnectionClosed",
",",
"proton",
".",
"MDisconnected",
":",
"for",
"l",
",",
"_",
":=",
"range",
"h",
".",
"receivers",
"{",
"h",
".",
"linkClosed",
"(",
"l",
",",
"nil",
")",
"\n",
"}",
"\n",
"for",
"l",
",",
"_",
":=",
"range",
"h",
".",
"senders",
"{",
"h",
".",
"linkClosed",
"(",
"l",
",",
"nil",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// 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",
"(",
"h",
".",
"senders",
",",
"l",
")",
"\n",
"}",
"else",
"if",
"r",
",",
"ok",
":=",
"h",
".",
"receivers",
"[",
"l",
"]",
";",
"ok",
"{",
"r",
".",
"stop",
"(",
")",
"\n",
"delete",
"(",
"h",
".",
"receivers",
",",
"l",
")",
"\n",
"}",
"\n",
"}"
] |
// 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.receivers[r.l] {
d.Accept() // Accept the delivery
r.l.Flow(1) // Add one credit
}
})
}
}
|
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.receivers[r.l] {
d.Accept() // Accept the delivery
r.l.Flow(1) // Add one credit
}
})
}
}
|
[
"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 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",
".",
"receivers",
"[",
"r",
".",
"l",
"]",
"{",
"d",
".",
"Accept",
"(",
")",
"// Accept the delivery",
"\n",
"r",
".",
"l",
".",
"Flow",
"(",
"1",
")",
"// Add one credit",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}",
"\n",
"}"
] |
// 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",
"send",
"a",
"credit",
"."
] |
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 closed
return
}
q = nil // Assume all credit will be used used, will be signaled otherwise.
s.h.injecter.Inject(func() { // Inject handler function to actually send
if s.h.senders[s.l] != s { // The sender has been closed by the remote end.
q.PutBack(m) // Put the message back on the queue but don't block
return
}
if s.sendOne(m) != nil {
return
}
// Send as many more messages as we can without blocking
for s.l.Credit() > 0 {
select { // Non blocking receive from q
case m, ok := <-s.q:
if ok {
s.sendOne(m)
}
default: // Queue is empty but we have credit, signal the run() goroutine.
s.sendable()
}
}
})
}
}
}
|
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 closed
return
}
q = nil // Assume all credit will be used used, will be signaled otherwise.
s.h.injecter.Inject(func() { // Inject handler function to actually send
if s.h.senders[s.l] != s { // The sender has been closed by the remote end.
q.PutBack(m) // Put the message back on the queue but don't block
return
}
if s.sendOne(m) != nil {
return
}
// Send as many more messages as we can without blocking
for s.l.Credit() > 0 {
select { // Non blocking receive from q
case m, ok := <-s.q:
if ok {
s.sendOne(m)
}
default: // Queue is empty but we have credit, signal the run() goroutine.
s.sendable()
}
}
})
}
}
}
|
[
"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",
"{",
"// sender closed",
"return",
"\n",
"}",
"\n",
"q",
"=",
"s",
".",
"q",
"// We have credit, enable selecting on the queue.",
"\n\n",
"case",
"m",
",",
"ok",
":=",
"<-",
"q",
":",
"// q is only enabled when we have credit.",
"if",
"!",
"ok",
"{",
"// queue closed",
"return",
"\n",
"}",
"\n",
"q",
"=",
"nil",
"// Assume all credit will be used used, will be signaled otherwise.",
"\n",
"s",
".",
"h",
".",
"injecter",
".",
"Inject",
"(",
"func",
"(",
")",
"{",
"// Inject handler function to actually send",
"if",
"s",
".",
"h",
".",
"senders",
"[",
"s",
".",
"l",
"]",
"!=",
"s",
"{",
"// The sender has been closed by the remote end.",
"q",
".",
"PutBack",
"(",
"m",
")",
"// Put the message back on the queue but don't block",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"s",
".",
"sendOne",
"(",
"m",
")",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"// Send as many more messages as we can without blocking",
"for",
"s",
".",
"l",
".",
"Credit",
"(",
")",
">",
"0",
"{",
"select",
"{",
"// Non blocking receive from q",
"case",
"m",
",",
"ok",
":=",
"<-",
"s",
".",
"q",
":",
"if",
"ok",
"{",
"s",
".",
"sendOne",
"(",
"m",
")",
"\n",
"}",
"\n",
"default",
":",
"// Queue is empty but we have credit, signal the run() goroutine.",
"s",
".",
"sendable",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// 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",
"(",
")",
"// Pre-settled, unreliable.",
"\n",
"debugf",
"(",
"\"",
"\"",
",",
"s",
".",
"l",
",",
"m",
")",
"\n",
"}",
"else",
"{",
"s",
".",
"q",
".",
"PutBack",
"(",
"m",
")",
"// Put the message back on the queue, don't block",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
// 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",
"}",
"\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",
")",
"\n",
"}",
"\n",
"}"
] |
// 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 should never store them as strings, and should overwrite your
// copy as soon as you are done with it.
//
|
[
"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",
"should",
"never",
"store",
"them",
"as",
"strings",
"and",
"should",
"overwrite",
"your",
"copy",
"as",
"soon",
"as",
"you",
"are",
"done",
"with",
"it",
"."
] |
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 := range opts {
opt(c)
// If the first option is not Server(), then we are a client.
// Applying Server() after other options is an error
if !c.server {
c.client = true
}
}
if c.container == nil {
// Generate a random container-id. Not an RFC4122-compliant UUID but probably-unique
id := make([]byte, 16)
if _, err = rand.Read(id); err != nil {
return nil, err
}
c.container = NewContainer(hex.EncodeToString(id)).(*container)
}
c.pConnection.SetContainer(c.container.Id())
saslConfig.setup(c.engine)
c.endpoint.init(c.engine.String())
go c.run()
return c, nil
}
|
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 := range opts {
opt(c)
// If the first option is not Server(), then we are a client.
// Applying Server() after other options is an error
if !c.server {
c.client = true
}
}
if c.container == nil {
// Generate a random container-id. Not an RFC4122-compliant UUID but probably-unique
id := make([]byte, 16)
if _, err = rand.Read(id); err != nil {
return nil, err
}
c.container = NewContainer(hex.EncodeToString(id)).(*container)
}
c.pConnection.SetContainer(c.container.Id())
saslConfig.setup(c.engine)
c.endpoint.init(c.engine.String())
go c.run()
return c, nil
}
|
[
"func",
"NewConnection",
"(",
"conn",
"net",
".",
"Conn",
",",
"opts",
"...",
"ConnectionOption",
")",
"(",
"*",
"connection",
",",
"error",
")",
"{",
"c",
":=",
"&",
"connection",
"{",
"conn",
":",
"conn",
",",
"}",
"\n",
"c",
".",
"handler",
"=",
"newHandler",
"(",
"c",
")",
"\n",
"var",
"err",
"error",
"\n",
"c",
".",
"engine",
",",
"err",
"=",
"proton",
".",
"NewEngine",
"(",
"c",
".",
"conn",
",",
"c",
".",
"handler",
".",
"delegator",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"c",
".",
"pConnection",
"=",
"c",
".",
"engine",
".",
"Connection",
"(",
")",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"c",
")",
"\n",
"// If the first option is not Server(), then we are a client.",
"// Applying Server() after other options is an error",
"if",
"!",
"c",
".",
"server",
"{",
"c",
".",
"client",
"=",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"c",
".",
"container",
"==",
"nil",
"{",
"// Generate a random container-id. Not an RFC4122-compliant UUID but probably-unique",
"id",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"16",
")",
"\n",
"if",
"_",
",",
"err",
"=",
"rand",
".",
"Read",
"(",
"id",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"c",
".",
"container",
"=",
"NewContainer",
"(",
"hex",
".",
"EncodeToString",
"(",
"id",
")",
")",
".",
"(",
"*",
"container",
")",
"\n",
"}",
"\n",
"c",
".",
"pConnection",
".",
"SetContainer",
"(",
"c",
".",
"container",
".",
"Id",
"(",
")",
")",
"\n",
"saslConfig",
".",
"setup",
"(",
"c",
".",
"engine",
")",
"\n",
"c",
".",
"endpoint",
".",
"init",
"(",
"c",
".",
"engine",
".",
"String",
"(",
")",
")",
"\n",
"go",
"c",
".",
"run",
"(",
")",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] |
// 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 the PLAIN mechanism without using SSL encryption.
//
// This default is to avoid disclosing password information accidentally over an
// insecure network.
//
|
[
"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",
"the",
"PLAIN",
"mechanism",
"without",
"using",
"SSL",
"encryption",
".",
"This",
"default",
"is",
"to",
"avoid",
"disclosing",
"password",
"information",
"accidentally",
"over",
"an",
"insecure",
"network",
"."
] |
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",
"}",
"\n",
"return",
"cont",
"\n",
"}"
] |
// 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",
"id",
"==",
"a",
"random",
"UUID",
"will",
"be",
"generated",
"for",
"the",
"id",
"."
] |
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",
".",
"running",
"\n",
"}"
] |
// 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",
"(",
")",
",",
"err",
")",
"}",
")",
"\n",
"select",
"{",
"case",
"<-",
"eng",
".",
"running",
":",
"case",
"<-",
"time",
".",
"After",
"(",
"timeout",
")",
":",
"eng",
".",
"Disconnect",
"(",
"err",
")",
"\n",
"}",
"\n",
"}"
] |
// 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",
"(",
")",
".",
"Tick",
"(",
"now",
")",
"\n",
"if",
"next",
"!=",
"0",
"{",
"eng",
".",
"timer",
".",
"Reset",
"(",
"time",
".",
"Duration",
"(",
"(",
"next",
"-",
"now",
")",
"*",
"int64",
"(",
"time",
".",
"Millisecond",
")",
")",
")",
"\n",
"}",
"\n",
"}"
] |
// 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); err == nil {
d.buffer.Next(n)
}
}
return
}
|
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); err == nil {
d.buffer.Next(n)
}
}
return
}
|
[
"func",
"(",
"d",
"*",
"Decoder",
")",
"Decode",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"data",
":=",
"C",
".",
"pn_data",
"(",
"0",
")",
"\n",
"defer",
"C",
".",
"pn_data_free",
"(",
"data",
")",
"\n",
"var",
"n",
"int",
"\n",
"for",
"n",
",",
"err",
"=",
"decode",
"(",
"data",
",",
"d",
".",
"buffer",
".",
"Bytes",
"(",
")",
")",
";",
"err",
"==",
"EndOfData",
";",
"{",
"err",
"=",
"d",
".",
"more",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"n",
",",
"err",
"=",
"decode",
"(",
"data",
",",
"d",
".",
"buffer",
".",
"Bytes",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
"==",
"nil",
"{",
"if",
"err",
"=",
"recoverUnmarshal",
"(",
"v",
",",
"data",
")",
";",
"err",
"==",
"nil",
"{",
"d",
".",
"buffer",
".",
"Next",
"(",
"n",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\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",
"AMQP",
"into",
"a",
"Go",
"value",
"."
] |
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 = io.EOF
}
return 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 = io.EOF
}
return err
}
|
[
"func",
"(",
"d",
"*",
"Decoder",
")",
"more",
"(",
")",
"error",
"{",
"var",
"readSize",
"int64",
"=",
"minDecode",
"\n",
"if",
"int64",
"(",
"d",
".",
"buffer",
".",
"Len",
"(",
")",
")",
">",
"readSize",
"{",
"// Grow by doubling",
"readSize",
"=",
"int64",
"(",
"d",
".",
"buffer",
".",
"Len",
"(",
")",
")",
"\n",
"}",
"\n",
"var",
"n",
"int64",
"\n",
"n",
",",
"err",
":=",
"d",
".",
"buffer",
".",
"ReadFrom",
"(",
"io",
".",
"LimitReader",
"(",
"d",
".",
"reader",
",",
"readSize",
")",
")",
"\n",
"if",
"n",
"==",
"0",
"&&",
"err",
"==",
"nil",
"{",
"// ReadFrom won't report io.EOF, just returns 0",
"err",
"=",
"io",
".",
"EOF",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] |
// 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
keyType := mapValue.Type().Key()
keyPtr := reflect.New(keyType)
valPtr := reflect.New(mapValue.Type().Elem())
for i := 0; i < n; i++ {
data.next(v)
unmarshal(keyPtr.Interface(), data)
if keyType.Kind() == reflect.Interface && !keyPtr.Elem().Elem().Type().Comparable() {
doPanicMsg(data, v, fmt.Sprintf("key %#v is not comparable", keyPtr.Elem().Interface()))
}
data.next(v)
unmarshal(valPtr.Interface(), data)
mapValue.SetMapIndex(keyPtr.Elem(), valPtr.Elem())
}
}
|
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
keyType := mapValue.Type().Key()
keyPtr := reflect.New(keyType)
valPtr := reflect.New(mapValue.Type().Elem())
for i := 0; i < n; i++ {
data.next(v)
unmarshal(keyPtr.Interface(), data)
if keyType.Kind() == reflect.Interface && !keyPtr.Elem().Elem().Type().Comparable() {
doPanicMsg(data, v, fmt.Sprintf("key %#v is not comparable", keyPtr.Elem().Interface()))
}
data.next(v)
unmarshal(valPtr.Interface(), data)
mapValue.SetMapIndex(keyPtr.Elem(), valPtr.Elem())
}
}
|
[
"func",
"getMap",
"(",
"data",
"*",
"C",
".",
"pn_data_t",
",",
"v",
"interface",
"{",
"}",
")",
"{",
"panicUnless",
"(",
"C",
".",
"pn_data_type",
"(",
"data",
")",
"==",
"C",
".",
"PN_MAP",
",",
"data",
",",
"v",
")",
"\n",
"n",
":=",
"int",
"(",
"C",
".",
"pn_data_get_map",
"(",
"data",
")",
")",
"/",
"2",
"\n",
"mapValue",
":=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
".",
"Elem",
"(",
")",
"\n",
"mapValue",
".",
"Set",
"(",
"reflect",
".",
"MakeMap",
"(",
"mapValue",
".",
"Type",
"(",
")",
")",
")",
"// Clear the map",
"\n",
"data",
".",
"enter",
"(",
"v",
")",
"\n",
"defer",
"data",
".",
"exit",
"(",
"v",
")",
"\n",
"// Allocate re-usable key/val values",
"keyType",
":=",
"mapValue",
".",
"Type",
"(",
")",
".",
"Key",
"(",
")",
"\n",
"keyPtr",
":=",
"reflect",
".",
"New",
"(",
"keyType",
")",
"\n",
"valPtr",
":=",
"reflect",
".",
"New",
"(",
"mapValue",
".",
"Type",
"(",
")",
".",
"Elem",
"(",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"data",
".",
"next",
"(",
"v",
")",
"\n",
"unmarshal",
"(",
"keyPtr",
".",
"Interface",
"(",
")",
",",
"data",
")",
"\n",
"if",
"keyType",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Interface",
"&&",
"!",
"keyPtr",
".",
"Elem",
"(",
")",
".",
"Elem",
"(",
")",
".",
"Type",
"(",
")",
".",
"Comparable",
"(",
")",
"{",
"doPanicMsg",
"(",
"data",
",",
"v",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"keyPtr",
".",
"Elem",
"(",
")",
".",
"Interface",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"data",
".",
"next",
"(",
"v",
")",
"\n",
"unmarshal",
"(",
"valPtr",
".",
"Interface",
"(",
")",
",",
"data",
")",
"\n",
"mapValue",
".",
"SetMapIndex",
"(",
"keyPtr",
".",
"Elem",
"(",
")",
",",
"valPtr",
".",
"Elem",
"(",
")",
")",
"\n",
"}",
"\n",
"}"
] |
// 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), nil
}
|
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), nil
}
|
[
"func",
"decode",
"(",
"data",
"*",
"C",
".",
"pn_data_t",
",",
"bytes",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
":=",
"C",
".",
"pn_data_decode",
"(",
"data",
",",
"cPtr",
"(",
"bytes",
")",
",",
"cLen",
"(",
"bytes",
")",
")",
"\n",
"if",
"n",
"==",
"C",
".",
"PN_UNDERFLOW",
"{",
"C",
".",
"pn_error_clear",
"(",
"C",
".",
"pn_data_error",
"(",
"data",
")",
")",
"\n",
"return",
"0",
",",
"EndOfData",
"\n",
"}",
"else",
"if",
"n",
"<=",
"0",
"{",
"return",
"0",
",",
"&",
"UnmarshalError",
"{",
"s",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"PnErrorCode",
"(",
"n",
")",
")",
"}",
"\n",
"}",
"\n",
"return",
"int",
"(",
"n",
")",
",",
"nil",
"\n",
"}"
] |
// 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",
"\"",
"\"",
"\n",
"case",
"Rejected",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Released",
":",
"return",
"\"",
"\"",
"\n",
"case",
"Unknown",
":",
"return",
"\"",
"\"",
"\n",
"default",
":",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n",
"}"
] |
// 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",
",",
"proton",
".",
"Modified",
":",
"return",
"Released",
"\n",
"default",
":",
"return",
"Unknown",
"\n",
"}",
"\n",
"}"
] |
// 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(err)
return
}
if s.SndSettle() == SndSettled || (s.SndSettle() == SndMixed && sm.ack == nil) {
d.Settle() // Pre-settled
Outcome{Accepted, nil, sm.v}.send(sm.ack) // Assume accepted
} else {
// Register with handler to receive the remote outcome
s.handler().sent[d] = sm
}
}
|
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(err)
return
}
if s.SndSettle() == SndSettled || (s.SndSettle() == SndMixed && sm.ack == nil) {
d.Settle() // Pre-settled
Outcome{Accepted, nil, sm.v}.send(sm.ack) // Assume accepted
} else {
// Register with handler to receive the remote outcome
s.handler().sent[d] = sm
}
}
|
[
"func",
"(",
"s",
"*",
"sender",
")",
"send",
"(",
"sm",
"*",
"sendable",
")",
"{",
"if",
"err",
":=",
"s",
".",
"Error",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"sm",
".",
"unsent",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"bytes",
",",
"err",
":=",
"s",
".",
"session",
".",
"connection",
".",
"mc",
".",
"Encode",
"(",
"sm",
".",
"m",
",",
"nil",
")",
"\n",
"close",
"(",
"sm",
".",
"sent",
")",
"// Safe to re-use sm.m now",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"sm",
".",
"unsent",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"d",
",",
"err",
":=",
"s",
".",
"pLink",
".",
"SendMessageBytes",
"(",
"bytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"sm",
".",
"unsent",
"(",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n",
"if",
"s",
".",
"SndSettle",
"(",
")",
"==",
"SndSettled",
"||",
"(",
"s",
".",
"SndSettle",
"(",
")",
"==",
"SndMixed",
"&&",
"sm",
".",
"ack",
"==",
"nil",
")",
"{",
"d",
".",
"Settle",
"(",
")",
"// Pre-settled",
"\n",
"Outcome",
"{",
"Accepted",
",",
"nil",
",",
"sm",
".",
"v",
"}",
".",
"send",
"(",
"sm",
".",
"ack",
")",
"// Assume accepted",
"\n",
"}",
"else",
"{",
"// Register with handler to receive the remote outcome",
"s",
".",
"handler",
"(",
")",
".",
"sent",
"[",
"d",
"]",
"=",
"sm",
"\n",
"}",
"\n",
"}"
] |
// 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",
"\n",
"}"
] |
// 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",
".",
"Pointer",
"(",
"ldbname",
")",
")",
"\n\n",
"C",
".",
"leveldb_repair_db",
"(",
"o",
".",
"Opt",
",",
"ldbname",
",",
"&",
"errStr",
")",
"\n",
"if",
"errStr",
"!=",
"nil",
"{",
"gs",
":=",
"C",
".",
"GoString",
"(",
"errStr",
")",
"\n",
"C",
".",
"leveldb_free",
"(",
"unsafe",
".",
"Pointer",
"(",
"errStr",
")",
")",
"\n",
"return",
"DatabaseError",
"(",
"gs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// 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.leveldb_free(unsafe.Pointer(errStr))
return DatabaseError(gs)
}
return nil
}
|
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.leveldb_free(unsafe.Pointer(errStr))
return DatabaseError(gs)
}
return nil
}
|
[
"func",
"(",
"db",
"*",
"DB",
")",
"Delete",
"(",
"wo",
"*",
"WriteOptions",
",",
"key",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"db",
".",
"closed",
"{",
"panic",
"(",
"ErrDBClosed",
")",
"\n",
"}",
"\n\n",
"var",
"errStr",
"*",
"C",
".",
"char",
"\n",
"var",
"k",
"*",
"C",
".",
"char",
"\n",
"if",
"len",
"(",
"key",
")",
"!=",
"0",
"{",
"k",
"=",
"(",
"*",
"C",
".",
"char",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"key",
"[",
"0",
"]",
")",
")",
"\n",
"}",
"\n\n",
"C",
".",
"leveldb_delete",
"(",
"db",
".",
"Ldb",
",",
"wo",
".",
"Opt",
",",
"k",
",",
"C",
".",
"size_t",
"(",
"len",
"(",
"key",
")",
")",
",",
"&",
"errStr",
")",
"\n\n",
"if",
"errStr",
"!=",
"nil",
"{",
"gs",
":=",
"C",
".",
"GoString",
"(",
"errStr",
")",
"\n",
"C",
".",
"leveldb_free",
"(",
"unsafe",
".",
"Pointer",
"(",
"errStr",
")",
")",
"\n",
"return",
"DatabaseError",
"(",
"gs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// 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",
"WriteOptions",
"passed",
"in",
"can",
"be",
"reused",
"by",
"multiple",
"calls",
"to",
"this",
"and",
"if",
"the",
"WriteOptions",
"is",
"left",
"unchanged",
"."
] |
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",
"\n",
"C",
".",
"leveldb_write",
"(",
"db",
".",
"Ldb",
",",
"wo",
".",
"Opt",
",",
"w",
".",
"wbatch",
",",
"&",
"errStr",
")",
"\n",
"if",
"errStr",
"!=",
"nil",
"{",
"gs",
":=",
"C",
".",
"GoString",
"(",
"errStr",
")",
"\n",
"C",
".",
"leveldb_free",
"(",
"unsafe",
".",
"Pointer",
"(",
"errStr",
")",
")",
"\n",
"return",
"DatabaseError",
"(",
"gs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// 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",
"value",
":=",
"C",
".",
"GoString",
"(",
"C",
".",
"leveldb_property_value",
"(",
"db",
".",
"Ldb",
",",
"cname",
")",
")",
"\n",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cname",
")",
")",
"\n",
"return",
"value",
"\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",
".",
"Ldb",
")",
"}",
"\n",
"}"
] |
// 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.ReleaseSnapshot method on the DB that
// created it.
//
// See the LevelDB documentation for details.
|
[
"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",
".",
"ReleaseSnapshot",
"method",
"on",
"the",
"DB",
"that",
"created",
"it",
".",
"See",
"the",
"LevelDB",
"documentation",
"for",
"details",
"."
] |
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",
".",
"snap",
")",
"\n",
"}"
] |
// 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",
"]",
")",
")",
",",
"C",
".",
"size_t",
"(",
"len",
"(",
"key",
")",
")",
")",
"\n",
"}"
] |
// 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",
"and",
"there",
"is",
"no",
"next",
"key",
"the",
"Iterator",
"becomes",
"invalid",
".",
"This",
"method",
"is",
"safe",
"to",
"call",
"when",
"Valid",
"returns",
"false",
"."
] |
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",
"{",
"gs",
":=",
"C",
".",
"GoString",
"(",
"errStr",
")",
"\n",
"C",
".",
"leveldb_free",
"(",
"unsafe",
".",
"Pointer",
"(",
"errStr",
")",
")",
"\n",
"return",
"IteratorError",
"(",
"gs",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// 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",
"=",
"body",
"\n\n",
"return",
"this",
"\n\n",
"}"
] |
// 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",
"copy",
"(",
"this",
".",
"Message",
".",
"RegistrationIds",
",",
"list",
")",
"\n\n",
"return",
"this",
"\n\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", this.apiKeyHeader())
request.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
return fcmRespStatus, err
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return fcmRespStatus, err
}
fcmRespStatus.StatusCode = response.StatusCode
fcmRespStatus.RetryAfter = response.Header.Get(retry_after_header)
if response.StatusCode != 200 {
return fcmRespStatus, nil
}
err = fcmRespStatus.parseStatusBody(body)
if err != nil {
return fcmRespStatus, err
}
fcmRespStatus.Ok = true
return fcmRespStatus, nil
}
|
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", this.apiKeyHeader())
request.Header.Set("Content-Type", "application/json")
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
return fcmRespStatus, err
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return fcmRespStatus, err
}
fcmRespStatus.StatusCode = response.StatusCode
fcmRespStatus.RetryAfter = response.Header.Get(retry_after_header)
if response.StatusCode != 200 {
return fcmRespStatus, nil
}
err = fcmRespStatus.parseStatusBody(body)
if err != nil {
return fcmRespStatus, err
}
fcmRespStatus.Ok = true
return fcmRespStatus, nil
}
|
[
"func",
"(",
"this",
"*",
"FcmClient",
")",
"sendOnce",
"(",
")",
"(",
"*",
"FcmResponseStatus",
",",
"error",
")",
"{",
"fcmRespStatus",
":=",
"new",
"(",
"FcmResponseStatus",
")",
"\n\n",
"jsonByte",
",",
"err",
":=",
"this",
".",
"Message",
".",
"toJsonByte",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fcmRespStatus",
",",
"err",
"\n",
"}",
"\n\n",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"fcmServerUrl",
",",
"bytes",
".",
"NewBuffer",
"(",
"jsonByte",
")",
")",
"\n",
"request",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"this",
".",
"apiKeyHeader",
"(",
")",
")",
"\n",
"request",
".",
"Header",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"client",
":=",
"&",
"http",
".",
"Client",
"{",
"}",
"\n",
"response",
",",
"err",
":=",
"client",
".",
"Do",
"(",
"request",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fcmRespStatus",
",",
"err",
"\n",
"}",
"\n",
"defer",
"response",
".",
"Body",
".",
"Close",
"(",
")",
"\n\n",
"body",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"response",
".",
"Body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fcmRespStatus",
",",
"err",
"\n",
"}",
"\n\n",
"fcmRespStatus",
".",
"StatusCode",
"=",
"response",
".",
"StatusCode",
"\n\n",
"fcmRespStatus",
".",
"RetryAfter",
"=",
"response",
".",
"Header",
".",
"Get",
"(",
"retry_after_header",
")",
"\n\n",
"if",
"response",
".",
"StatusCode",
"!=",
"200",
"{",
"return",
"fcmRespStatus",
",",
"nil",
"\n",
"}",
"\n\n",
"err",
"=",
"fcmRespStatus",
".",
"parseStatusBody",
"(",
"body",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fcmRespStatus",
",",
"err",
"\n",
"}",
"\n",
"fcmRespStatus",
".",
"Ok",
"=",
"true",
"\n\n",
"return",
"fcmRespStatus",
",",
"nil",
"\n",
"}"
] |
// 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",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n\n",
"}"
] |
// 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",
".",
"Message",
".",
"Priority",
"=",
"Priority_NORMAL",
"\n",
"}",
"\n\n",
"return",
"this",
"\n",
"}"
] |
// 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",
"inactive",
"client",
"app",
"is",
"awoken",
".",
"On",
"Android",
"data",
"messages",
"wake",
"the",
"app",
"by",
"default",
".",
"On",
"Chrome",
"currently",
"not",
"supported",
"."
] |
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
No community queries yet
The top public SQL queries from the community will appear here once available.