You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/09/01 15:04:18 UTC

[50/50] qpid-proton git commit: Merge branch 'master' into go1

Merge branch 'master' into go1

Latest go updates


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3d8368b2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3d8368b2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3d8368b2

Branch: refs/heads/go1
Commit: 3d8368b2e730644685d5a6734b5f60831514a5f4
Parents: 847a83c cf38e3d
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Sep 1 11:02:44 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri Sep 1 11:02:44 2017 -0400

----------------------------------------------------------------------
 amqp/doc.go     | 2 +-
 electron/doc.go | 2 +-
 proton/doc.go   | 2 +-
 proton/error.go | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d8368b2/amqp/doc.go
----------------------------------------------------------------------
diff --cc amqp/doc.go
index 701af55,0000000..c04c2b0
mode 100644,000000..100644
--- a/amqp/doc.go
+++ b/amqp/doc.go
@@@ -1,38 -1,0 +1,38 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +/*
 +Package amqp encodes and decodes AMQP 1.0 messages and data types as Go types.
 +
 +It follows the standard 'encoding' libraries pattern. The mapping between AMQP
 +and Go types is described in the documentation of the Marshal and Unmarshal
 +functions.
 +
 +This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
 +
 +Package 'electron' is a full AMQP 1.0 client/server toolkit using this package.
 +
 +AMQP 1.0 is an open standard for inter-operable message exchange, see <http://www.amqp.org/>
 +*/
 +package amqp
 +
- // #cgo LDFLAGS: -lqpid-proton
++// #cgo LDFLAGS: -lqpid-proton-core
 +import "C"
 +
 +// This file is just for the package comment.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d8368b2/electron/doc.go
----------------------------------------------------------------------
diff --cc electron/doc.go
index f4baa31,0000000..39137c0
mode 100644,000000..100644
--- a/electron/doc.go
+++ b/electron/doc.go
@@@ -1,73 -1,0 +1,73 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +/*
 +Package electron lets you write concurrent AMQP 1.0 messaging clients and servers.
 +
 +This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
 +
 +Start by creating a Container with NewContainer. An AMQP Container represents a
 +single AMQP "application" and can contain client and server connections.
 +
 +You can enable AMQP over any connection that implements the standard net.Conn
 +interface. Typically you can connect with net.Dial() or listen for server
 +connections with net.Listen.  Enable AMQP by passing the net.Conn to
 +Container.Connection().
 +
 +AMQP allows bi-direction peer-to-peer message exchange as well as
 +client-to-broker. Messages are sent over "links". Each link is one-way and has a
 +Sender and Receiver end. Connection.Sender() and Connection.Receiver() open
 +links to Send() and Receive() messages. Connection.Incoming() lets you accept
 +incoming links opened by the remote peer. You can open and accept multiple links
 +in both directions on a single Connection.
 +
 +Some of the documentation examples show client and server side by side in a
 +single program, in separate goroutines. This is only for example purposes, real
 +AMQP applications would run in separate processes on the network.
 +More realistic examples: https://github.com/apache/qpid-proton/blob/master/examples/go/README.md
 +
 +Some of the documentation examples show client and server side by side in a
 +single program, in separate goroutines. This is only for example purposes, real
 +AMQP applications would run in separate processes on the network.
 +More realistic examples: https://github.com/apache/qpid-proton/blob/master/examples/go/README.md
 +
 +*/
 +package electron
 +
- //#cgo LDFLAGS: -lqpid-proton
++//#cgo LDFLAGS: -lqpid-proton-core
 +import "C"
 +
 +// Just for package comment
 +
 +/* DEVELOPER NOTES
 +
 +There is a single proton.Engine per connection, each driving it's own event-loop goroutine,
 +and each with a 'handler'. Most state for a connection is maintained on the handler, and
 +only accessed in the event-loop goroutine, so no locks are required there.
 +
 +The handler sets up channels as needed to get or send data from user goroutines
 +using electron types like Sender or Receiver.
 +
 +Engine.Inject injects actions into the event loop from user goroutines. It is
 +important to check at the start of an injected function that required objects
 +are still valid, for example a link may be remotely closed between the time a
 +Sender function calls Inject and the time the injected function is execute by
 +the handler goroutine.
 +
 +*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d8368b2/proton/doc.go
----------------------------------------------------------------------
diff --cc proton/doc.go
index 1049e71,0000000..39716e2
mode 100644,000000..100644
--- a/proton/doc.go
+++ b/proton/doc.go
@@@ -1,66 -1,0 +1,66 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +/*
 +Package proton wraps Proton-C, an event-driven, concurrent-unsafe AMQP 1.0
 +C library (package 'electron' is more "Go-like" and concurrent-safe)
 +
 +This package requires the [proton-C library](http://qpid.apache.org/proton) to be installed.
 +
 +Consult the C API documentation at http://qpid.apache.org/proton for more
 +information about the types here. There is a 1-1 correspondence between C type
 +pn_foo_t and Go type proton.Foo, and between C function
 +
 +    pn_foo_do_something(pn_foo_t*, ...)
 +
 +and Go method
 +
 +    func (proton.Foo) DoSomething(...)
 +
 +The proton.Engine type pumps data between a Go net.Conn and a proton event loop
 +goroutine that feeds events to a proton.MessagingHandler, which you must implement.
 +See the Engine documentation for more.
 +
 +MessagingHandler defines an event handling interface that you can implement to
 +react to AMQP protocol events. There is also a lower-level EventHandler, but
 +MessagingHandler provides a simpler set of events and automates common tasks for you,
 +for most applications it will be more convenient.
 +
 +NOTE: Methods on most types defined in this package (Sessions, Links etc.)  can
 +*only* be called in the event handler goroutine of the relevant
 +Connection/Engine, either by the HandleEvent method of a handler type or in a
 +function injected into the goroutine via Inject() or InjectWait() Handlers and
 +injected functions can set up channels to communicate with other goroutines.
 +Note the Injecter associated with a handler available as part of the Event value
 +passed to HandleEvent.
 +
 +Separate Engine instances are independent, and can run concurrently.
 +
 +The 'electron' package is built on the proton package but instead offers a
 +concurrent-safe API that can use simple procedural loops rather than event
 +handlers to express application logic. It is easier to use for most
 +applications.
 +
 +*/
 +package proton
 +
- // #cgo LDFLAGS: -lqpid-proton
++// #cgo LDFLAGS: -lqpid-proton-core
 +import "C"
 +
 +// This file is just for the package comment.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d8368b2/proton/error.go
----------------------------------------------------------------------
diff --cc proton/error.go
index 80d9680,0000000..5232fec
mode 100644,000000..100644
--- a/proton/error.go
+++ b/proton/error.go
@@@ -1,96 -1,0 +1,96 @@@
 +/*
 +Licensed to the Apache Software Foundation (ASF) under one
 +or more contributor license agreements.  See the NOTICE file
 +distributed with this work for additional information
 +regarding copyright ownership.  The ASF licenses this file
 +to you under the Apache License, Version 2.0 (the
 +"License"); you may not use this file except in compliance
 +with the License.  You may obtain a copy of the License at
 +
 +  http://www.apache.org/licenses/LICENSE-2.0
 +
 +Unless required by applicable law or agreed to in writing,
 +software distributed under the License is distributed on an
 +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +KIND, either express or implied.  See the License for the
 +specific language governing permissions and limitations
 +under the License.
 +*/
 +
 +// Internal implementation details - ignore.
 +package proton
 +
- // #cgo LDFLAGS: -lqpid-proton
++// #cgo LDFLAGS: -lqpid-proton-core
 +// #include <proton/error.h>
 +// #include <proton/codec.h>
 +import "C"
 +
 +import (
 +	"fmt"
 +	"sync"
 +	"sync/atomic"
 +)
 +
 +type PnErrorCode int
 +
 +func (e PnErrorCode) String() string {
 +	switch e {
 +	case C.PN_EOS:
 +		return "end-of-data"
 +	case C.PN_ERR:
 +		return "error"
 +	case C.PN_OVERFLOW:
 +		return "overflow"
 +	case C.PN_UNDERFLOW:
 +		return "underflow"
 +	case C.PN_STATE_ERR:
 +		return "bad-state"
 +	case C.PN_ARG_ERR:
 +		return "invalid-argument"
 +	case C.PN_TIMEOUT:
 +		return "timeout"
 +	case C.PN_INTR:
 +		return "interrupted"
 +	case C.PN_INPROGRESS:
 +		return "in-progress"
 +	default:
 +		return fmt.Sprintf("unknown-error(%d)", e)
 +	}
 +}
 +
 +func PnError(e *C.pn_error_t) error {
 +	if e == nil || C.pn_error_code(e) == 0 {
 +		return nil
 +	}
 +	return fmt.Errorf("%s: %s", PnErrorCode(C.pn_error_code(e)), C.GoString(C.pn_error_text(e)))
 +}
 +
 +// ErrorHolder is a goroutine-safe error holder that keeps the first error that is set.
 +type ErrorHolder struct {
 +	once  sync.Once
 +	value atomic.Value
 +}
 +
 +// Set the error if not already set, return the error in the Holder.
 +func (e *ErrorHolder) Set(err error) {
 +	if err != nil {
 +		e.once.Do(func() { e.value.Store(err) })
 +	}
 +}
 +
 +// Get the error.
 +func (e *ErrorHolder) Get() (err error) {
 +	err, _ = e.value.Load().(error)
 +	return
 +}
 +
 +// assert panics if condition is false with optional formatted message
 +func assert(condition bool, format ...interface{}) {
 +	if !condition {
 +		if len(format) > 0 {
 +			panic(fmt.Errorf(format[0].(string), format[1:]...))
 +		} else {
 +			panic(fmt.Errorf("assertion failed"))
 +		}
 +	}
 +}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org