| 1 |
/* |
| 2 |
Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
or more contributor license agreements. See the NOTICE file |
| 4 |
distributed with this work for additional information |
| 5 |
regarding copyright ownership. The ASF licenses this file |
| 6 |
to you under the Apache License, Version 2.0 (the |
| 7 |
"License"); you may not use this file except in compliance |
| 8 |
with the License. You may obtain a copy of the License at |
| 9 |
|
| 10 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 12 |
Unless required by applicable law or agreed to in writing, |
| 13 |
software distributed under the License is distributed on an |
| 14 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
KIND, either express or implied. See the License for the |
| 16 |
specific language governing permissions and limitations |
| 17 |
under the License. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
Package electron lets you write concurrent AMQP 1.0 messaging clients and servers. |
| 22 |
|
| 23 |
This package requires the [proton-C library](http://github.com/apache/qpid-proton/go/pkg/proton) to be installed. |
| 24 |
|
| 25 |
Start by creating a Container with NewContainer. An AMQP Container represents a |
| 26 |
single AMQP "application" and can contain client and server connections. |
| 27 |
|
| 28 |
You can enable AMQP over any connection that implements the standard net.Conn |
| 29 |
interface. Typically you can connect with net.Dial() or listen for server |
| 30 |
connections with net.Listen. Enable AMQP by passing the net.Conn to |
| 31 |
Container.Connection(). |
| 32 |
|
| 33 |
AMQP allows bi-direction peer-to-peer message exchange as well as |
| 34 |
client-to-broker. Messages are sent over "links". Each link is one-way and has a |
| 35 |
Sender and Receiver end. Connection.Sender() and Connection.Receiver() open |
| 36 |
links to Send() and Receive() messages. Connection.Incoming() lets you accept |
| 37 |
incoming links opened by the remote peer. You can open and accept multiple links |
| 38 |
in both directions on a single Connection. |
| 39 |
|
| 40 |
Some of the documentation examples show client and server side by side in a |
| 41 |
single program, in separate goroutines. This is only for example purposes, real |
| 42 |
AMQP applications would run in separate processes on the network. |
| 43 |
|
| 44 |
Some of the documentation examples show client and server side by side in a |
| 45 |
single program, in separate goroutines. This is only for example purposes, real |
| 46 |
AMQP applications would run in separate processes on the network. |
| 47 |
*/ |
| 48 |
package electron |
| 49 |
|
| 50 |
//#cgo LDFLAGS: -lqpid-proton-core |
| 51 |
import "C" |
| 52 |
|
| 53 |
// Just for package comment |
| 54 |
|
| 55 |
/* DEVELOPER NOTES |
| 56 |
|
| 57 |
There is a single proton.Engine per connection, each driving it's own event-loop goroutine, |
| 58 |
and each with a 'handler'. Most state for a connection is maintained on the handler, and |
| 59 |
only accessed in the event-loop goroutine, so no locks are required there. |
| 60 |
|
| 61 |
The handler sets up channels as needed to get or send data from user goroutines |
| 62 |
using electron types like Sender or Receiver. |
| 63 |
|
| 64 |
Engine.Inject injects actions into the event loop from user goroutines. It is |
| 65 |
important to check at the start of an injected function that required objects |
| 66 |
are still valid, for example a link may be remotely closed between the time a |
| 67 |
Sender function calls Inject and the time the injected function is execute by |
| 68 |
the handler goroutine. |
| 69 |
|
| 70 |
*/ |