v0.0.0-...-f8fd68f Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0



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]( to be installed.

Consult the C API documentation at 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.

Internal implementation details - ignore.



View Source
const (
	SLocalUninit  State = C.PN_LOCAL_UNINIT
	SLocalActive        = C.PN_LOCAL_ACTIVE
	SLocalClosed        = C.PN_LOCAL_CLOSED
	SRemoteUninit       = C.PN_REMOTE_UNINIT
	SRemoteActive       = C.PN_REMOTE_ACTIVE
	SRemoteClosed       = C.PN_REMOTE_CLOSED
View Source
const (
	Received uint64 = C.PN_RECEIVED
	Accepted        = C.PN_ACCEPTED
	Rejected        = C.PN_REJECTED
	Released        = C.PN_RELEASED
	Modified        = C.PN_MODIFIED


This section is empty.


func CloseError

func CloseError(e Endpoint, err error)

CloseError sets an error condition (if err != nil) on an endpoint and closes the endpoint if not already closed

func Decref

func Decref(c CHandle)

Decref decreases the refcount of a proton value, freeing the underlying C struct if this is the last reference. Only call this if you previously called Incref() for this value.

func EndpointError

func EndpointError(e Endpoint) error

EndpointError returns the remote error if there is one, the local error if not nil if there is no error.

func Incref

func Incref(c CHandle)

Incref increases the refcount of a proton value, which prevents the underlying C struct being freed until you call Decref().

It can be useful to "pin" a proton value in memory while it is in use by goroutines other than the event loop goroutine. For example if you Incref() a Link, the underlying object is not freed when the link is closed, so means other goroutines can continue to safely use it as an index in a map or inject it into the event loop goroutine. There will of course be an error if you try to use a link after it is closed, but not a segmentation fault.

func PnError

func PnError(e *C.pn_error_t) error

func SASLExtended

func SASLExtended() bool

Do we support extended SASL negotiation? All implementations of Proton support ANONYMOUS and EXTERNAL on both client and server sides and PLAIN on the client side.

Extended SASL implememtations use an external library (Cyrus SASL) to support other mechanisms beyond these basic ones.


type CHandle

type CHandle interface {
	// CPtr returns the unsafe C pointer, equivalent to a C void*.
	CPtr() unsafe.Pointer

CHandle holds an unsafe.Pointer to a proton C struct, the C type depends on the Go type implementing this interface. For low level, at-your-own-risk use only.

type Condition

type Condition struct {
	// contains filtered or unexported fields

func (Condition) CPtr

func (c Condition) CPtr() unsafe.Pointer

func (Condition) Clear

func (c Condition) Clear()

func (Condition) Copy

func (c Condition) Copy(src Condition) int

func (Condition) Description

func (c Condition) Description() string

func (Condition) Error

func (c Condition) Error() error

Error returns an instance of amqp.Error or nil.

func (Condition) Info

func (c Condition) Info() Data

func (Condition) IsNil

func (c Condition) IsNil() bool

func (Condition) IsRedirect

func (c Condition) IsRedirect() bool

func (Condition) IsSet

func (c Condition) IsSet() bool

func (Condition) Name

func (c Condition) Name() string

func (Condition) RedirectHost

func (c Condition) RedirectHost() string

func (Condition) RedirectPort

func (c Condition) RedirectPort() int

func (Condition) SetDescription

func (c Condition) SetDescription(description string) int

func (Condition) SetError

func (c Condition) SetError(err error)

Set a Go error into a condition, converting to an amqp.Error using amqp.MakeError

func (Condition) SetName

func (c Condition) SetName(name string) int

type Connection

type Connection struct {
	// contains filtered or unexported fields

func (Connection) CPtr

func (c Connection) CPtr() unsafe.Pointer

func (Connection) Close

func (c Connection) Close()

func (Connection) Condition

func (c Connection) Condition() Condition

func (Connection) Container

func (c Connection) Container() string

func (Connection) DesiredCapabilities

func (c Connection) DesiredCapabilities() Data

func (Connection) Error

func (c Connection) Error() error

func (Connection) Free

func (c Connection) Free()

func (Connection) Hostname

func (c Connection) Hostname() string

func (Connection) IsNil

func (c Connection) IsNil() bool

func (Connection) LinkHead

func (c Connection) LinkHead(s State) Link
func (c Connection) Links(state State) (links []Link)

func (Connection) OfferedCapabilities

func (c Connection) OfferedCapabilities() Data

func (Connection) Open

func (c Connection) Open()

func (Connection) Properties

func (c Connection) Properties() Data

func (Connection) Release

func (c Connection) Release()

func (Connection) RemoteCondition

func (c Connection) RemoteCondition() Condition

func (Connection) RemoteContainer

func (c Connection) RemoteContainer() string

func (Connection) RemoteDesiredCapabilities

func (c Connection) RemoteDesiredCapabilities() Data

func (Connection) RemoteHostname

func (c Connection) RemoteHostname() string

func (Connection) RemoteOfferedCapabilities

func (c Connection) RemoteOfferedCapabilities() Data

func (Connection) RemoteProperties

func (c Connection) RemoteProperties() Data

func (Connection) Reset

func (c Connection) Reset()

func (Connection) Session

func (c Connection) Session() (Session, error)

func (Connection) SessionHead

func (c Connection) SessionHead(s State) Session

func (Connection) Sessions

func (c Connection) Sessions(state State) (sessions []Session)

func (Connection) SetContainer

func (c Connection) SetContainer(container string)

func (Connection) SetHostname

func (c Connection) SetHostname(hostname string)

func (Connection) SetPassword

func (c Connection) SetPassword(password []byte)

SetPassword takes []byte not string because it is impossible to erase a string from memory reliably. Proton will not keep the password in memory longer than needed, the caller should overwrite their copy on return.

The password must not contain embedded nul characters, a trailing nul is ignored.

func (Connection) SetUser

func (c Connection) SetUser(user string)

func (Connection) State

func (c Connection) State() State

func (Connection) String

func (c Connection) String() string

Unique (per process) string identifier for a connection, useful for debugging.

func (Connection) Transport

func (c Connection) Transport() Transport

func (Connection) Type

func (c Connection) Type() string

func (Connection) User

func (c Connection) User() string

type Data

type Data struct {
	// contains filtered or unexported fields

Data is an intermediate form of decoded AMQP data.

func (Data) CPtr

func (d Data) CPtr() unsafe.Pointer

func (Data) Clear

func (d Data) Clear()

func (Data) Empty

func (d Data) Empty() bool

func (Data) Error

func (d Data) Error() error

func (Data) Free

func (d Data) Free()

func (Data) Marshal

func (d Data) Marshal(v interface{}) error

Marshal the value v into d, see amqp.Marshal() for details

func (Data) Next

func (d Data) Next()

func (Data) Rewind

func (d Data) Rewind()

func (Data) String

func (d Data) String() string

func (Data) Unmarshal

func (d Data) Unmarshal(ptr interface{}) error

Unmarshal the value of d into value pointed at by ptr, see amqp.Unmarshal() for details

type Delivery

type Delivery struct {
	// contains filtered or unexported fields

func (Delivery) Abort

func (d Delivery) Abort()

func (Delivery) Aborted

func (d Delivery) Aborted() bool

func (Delivery) Accept

func (d Delivery) Accept()

Accept accepts and settles a delivery.

func (Delivery) Buffered

func (d Delivery) Buffered() bool

func (Delivery) CPtr

func (d Delivery) CPtr() unsafe.Pointer

func (Delivery) Clear

func (d Delivery) Clear()

func (Delivery) Current

func (d Delivery) Current() bool

func (Delivery) Dump

func (d Delivery) Dump()

func (Delivery) HasMessage

func (d Delivery) HasMessage() bool

HasMessage is true if all message data is available. Equivalent to !d.isNil && d.Readable() && !d.Partial()

func (Delivery) IsNil

func (d Delivery) IsNil() bool
func (d Delivery) Link() Link

func (Delivery) Local

func (d Delivery) Local() Disposition

func (Delivery) LocalState

func (d Delivery) LocalState() uint64

func (Delivery) Message

func (delivery Delivery) Message() (amqp.Message, error)

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.

func (Delivery) MessageBytes

func (delivery Delivery) MessageBytes() ([]byte, error)

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.

func (Delivery) Partial

func (d Delivery) Partial() bool

func (Delivery) Pending

func (d Delivery) Pending() uint

func (Delivery) Readable

func (d Delivery) Readable() bool

func (Delivery) Reject

func (d Delivery) Reject()

Reject rejects and settles a delivery

func (Delivery) Release

func (d Delivery) Release(delivered bool)

Release releases and settles a delivery If delivered is true the delivery count for the message will be increased.

func (Delivery) Remote

func (d Delivery) Remote() Disposition

func (Delivery) RemoteState

func (d Delivery) RemoteState() uint64

func (Delivery) Settle

func (d Delivery) Settle()

func (Delivery) SettleAs

func (d Delivery) SettleAs(disposition uint64)

SettleAs is equivalent to d.Update(disposition); d.Settle()

func (Delivery) Settled

func (d Delivery) Settled() bool

func (Delivery) Tag

func (d Delivery) Tag() DeliveryTag

func (Delivery) Update

func (d Delivery) Update(state uint64)

func (Delivery) Updated

func (d Delivery) Updated() bool

func (Delivery) Writable

func (d Delivery) Writable() bool

type DeliveryTag

type DeliveryTag struct {
	// contains filtered or unexported fields

func (DeliveryTag) String

func (t DeliveryTag) String() string

type Disposition

type Disposition struct {
	// contains filtered or unexported fields

func (Disposition) Annotations

func (d Disposition) Annotations() Data

func (Disposition) CPtr

func (d Disposition) CPtr() unsafe.Pointer

func (Disposition) Condition

func (d Disposition) Condition() Condition

func (Disposition) Data

func (d Disposition) Data() Data

func (Disposition) IsFailed

func (d Disposition) IsFailed() bool

func (Disposition) IsNil

func (d Disposition) IsNil() bool

func (Disposition) IsUndeliverable

func (d Disposition) IsUndeliverable() bool

func (Disposition) SectionNumber

func (d Disposition) SectionNumber() uint16

func (Disposition) SectionOffset

func (d Disposition) SectionOffset() uint64

func (Disposition) SetFailed

func (d Disposition) SetFailed(failed bool)

func (Disposition) SetSectionNumber

func (d Disposition) SetSectionNumber(section_number uint16)

func (Disposition) SetSectionOffset

func (d Disposition) SetSectionOffset(section_offset uint64)

func (Disposition) SetUndeliverable

func (d Disposition) SetUndeliverable(undeliverable bool)

func (Disposition) Type

func (d Disposition) Type() uint64

type DistributionMode

type DistributionMode C.pn_distribution_mode_t

func (DistributionMode) String

func (e DistributionMode) String() string

type Durability

type Durability C.pn_durability_t
const (
	Nondurable    Durability = C.PN_NONDURABLE
	Configuration Durability = C.PN_CONFIGURATION
	Deliveries    Durability = C.PN_DELIVERIES

func (Durability) String

func (e Durability) String() string

type Endpoint

type Endpoint interface {
	// State is the open/closed state.
	State() State
	// Open an endpoint.
	// Close an endpoint.
	// Condition holds a local error condition.
	Condition() Condition
	// RemoteCondition holds a remote error condition.
	RemoteCondition() Condition
	// Human readable name
	String() string
	// Human readable endpoint type "sender-link", "session" etc.
	Type() string

Endpoint is the common interface for Connection, Link and Session.

type Engine

type Engine struct {
	// contains filtered or unexported fields

Engine reads from a net.Conn, decodes AMQP events and calls the appropriate Handler functions sequentially in a single goroutine. Actions taken by Handler functions (such as sending messages) are encoded and written to the net.Conn. You can create multiple Engines to handle multiple connections concurrently.

You implement the EventHandler and/or MessagingHandler interfaces and provide those values to NewEngine(). Their HandleEvent method will be called in the event-handling goroutine.

Handlers can pass values from an event (Connections, Links, Deliveries etc.) to other goroutines, store them, or use them as map indexes. Effectively they are just pointers. Other goroutines cannot call their methods directly but they can can create a function closure to call such methods and pass it to Engine.Inject() to have it evaluated in the engine goroutine.

You are responsible for ensuring you don't use an event value after it is invalid. The handler methods will tell you when a value is no longer valid. For example after a LinkClosed event, that link is no longer valid. If you do Link.Close() yourself (in a handler or injected function) the link remains valid until the corresponding LinkClosed event is received by the handler.

Engine.Close() will take care of cleaning up any remaining values when you are done with the Engine. All values associated with a engine become invalid when you call Engine.Close()

The package will do all this for you, so it may be a better choice for some applications.

func NewEngine

func NewEngine(conn net.Conn, handlers ...EventHandler) (*Engine, error)

Create a new Engine and call Initialize() with conn and handlers

func (*Engine) Close

func (eng *Engine) Close(err error)

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.

func (*Engine) CloseTimeout

func (eng *Engine) CloseTimeout(err error, timeout time.Duration)

CloseTimeout like Close but disconnect if the remote end doesn't close within timeout.

func (*Engine) Connection

func (eng *Engine) Connection() Connection

func (*Engine) Disconnect

func (eng *Engine) Disconnect(err error)

Disconnect the engine's connection immediately without an AMQP close. Process any termination events before returning.

func (*Engine) Error

func (eng *Engine) Error() error

func (*Engine) Id

func (eng *Engine) Id() string

func (*Engine) Initialize

func (eng *Engine) Initialize(conn net.Conn, handlers ...EventHandler) error

Initialize an Engine with a connection and handlers. Start it with Run()

func (*Engine) Inject

func (eng *Engine) Inject(f func()) error

Inject a function into the Engine's event loop.

f() will be called in the same event-processing goroutine that calls Handler methods. f() can safely call methods on values that belong to this engine (Sessions, Links etc)

The injected function has no parameters or return values. It is normally a closure and can use channels to communicate with the injecting goroutine if necessary.

Returns a non-nil error if the engine is closed before the function could be injected.

func (*Engine) InjectWait

func (eng *Engine) InjectWait(f func() error) error

InjectWait is like Inject but does not return till f() has completed or the engine is closed, and returns an error value from f()

func (*Engine) Run

func (eng *Engine) Run() error

Run the engine. Engine.Run() will exit when the engine is closed or disconnected. You can check for errors after exit with Engine.Error().

func (*Engine) Server

func (eng *Engine) Server()

Server puts the Engine in server mode, meaning it will auto-detect security settings on the incoming connection such as use of SASL and SSL. Must be called before Run()

func (*Engine) String

func (eng *Engine) String() string

func (*Engine) Transport

func (eng *Engine) Transport() Transport

type ErrorHolder

type ErrorHolder struct {
	// contains filtered or unexported fields

ErrorHolder is a goroutine-safe error holder that keeps the first error that is set.

func (*ErrorHolder) Get

func (e *ErrorHolder) Get() (err error)

Get the error.

func (*ErrorHolder) Set

func (e *ErrorHolder) Set(err error)

Set the error if not already set

type Event

type Event struct {
	// contains filtered or unexported fields

Event is an AMQP protocol event.

func (Event) Connection

func (e Event) Connection() Connection

func (Event) Delivery

func (e Event) Delivery() Delivery

func (Event) Injecter

func (e Event) Injecter() Injecter

Injecter should not be used in a handler function, but it can be passed to other goroutines (via a channel or to a goroutine started by handler functions) to let them inject functions back into the handlers goroutine.

func (Event) IsNil

func (e Event) IsNil() bool
func (e Event) Link() Link

func (Event) Session

func (e Event) Session() Session

func (Event) String

func (e Event) String() string

func (Event) Transport

func (e Event) Transport() Transport

func (Event) Type

func (e Event) Type() EventType

type EventHandler

type EventHandler interface {
	// HandleEvent is called with an event.
	// Typically HandleEvent() is implemented as a switch on e.Type()
	HandleEvent(e Event)

EventHandler handles core proton events.

type EventType

type EventType int
const (
	EConnectionInit         EventType = C.PN_CONNECTION_INIT
	EConnectionBound        EventType = C.PN_CONNECTION_BOUND
	EConnectionUnbound      EventType = C.PN_CONNECTION_UNBOUND
	EConnectionLocalOpen    EventType = C.PN_CONNECTION_LOCAL_OPEN
	EConnectionRemoteOpen   EventType = C.PN_CONNECTION_REMOTE_OPEN
	EConnectionLocalClose   EventType = C.PN_CONNECTION_LOCAL_CLOSE
	EConnectionRemoteClose  EventType = C.PN_CONNECTION_REMOTE_CLOSE
	EConnectionFinal        EventType = C.PN_CONNECTION_FINAL
	ESessionInit            EventType = C.PN_SESSION_INIT
	ESessionLocalOpen       EventType = C.PN_SESSION_LOCAL_OPEN
	ESessionRemoteOpen      EventType = C.PN_SESSION_REMOTE_OPEN
	ESessionLocalClose      EventType = C.PN_SESSION_LOCAL_CLOSE
	ESessionRemoteClose     EventType = C.PN_SESSION_REMOTE_CLOSE
	ESessionFinal           EventType = C.PN_SESSION_FINAL
	ELinkInit               EventType = C.PN_LINK_INIT
	ELinkLocalOpen          EventType = C.PN_LINK_LOCAL_OPEN
	ELinkRemoteOpen         EventType = C.PN_LINK_REMOTE_OPEN
	ELinkLocalClose         EventType = C.PN_LINK_LOCAL_CLOSE
	ELinkRemoteClose        EventType = C.PN_LINK_REMOTE_CLOSE
	ELinkLocalDetach        EventType = C.PN_LINK_LOCAL_DETACH
	ELinkRemoteDetach       EventType = C.PN_LINK_REMOTE_DETACH
	ELinkFlow               EventType = C.PN_LINK_FLOW
	ELinkFinal              EventType = C.PN_LINK_FINAL
	EDelivery               EventType = C.PN_DELIVERY
	ETransport              EventType = C.PN_TRANSPORT
	ETransportAuthenticated EventType = C.PN_TRANSPORT_AUTHENTICATED
	ETransportError         EventType = C.PN_TRANSPORT_ERROR
	ETransportHeadClosed    EventType = C.PN_TRANSPORT_HEAD_CLOSED
	ETransportTailClosed    EventType = C.PN_TRANSPORT_TAIL_CLOSED
	ETransportClosed        EventType = C.PN_TRANSPORT_CLOSED
	EConnectionWake         EventType = C.PN_CONNECTION_WAKE
	EListenerAccept         EventType = C.PN_LISTENER_ACCEPT
	EListenerClose          EventType = C.PN_LISTENER_CLOSE
	EProactorInterrupt      EventType = C.PN_PROACTOR_INTERRUPT
	EProactorTimeout        EventType = C.PN_PROACTOR_TIMEOUT
	EProactorInactive       EventType = C.PN_PROACTOR_INACTIVE
	EListenerOpen           EventType = C.PN_LISTENER_OPEN

func (EventType) String

func (e EventType) String() string

type ExpiryPolicy

type ExpiryPolicy C.pn_expiry_policy_t
const (
	ExpireWithLink       ExpiryPolicy = C.PN_EXPIRE_WITH_LINK
	ExpireWithSession    ExpiryPolicy = C.PN_EXPIRE_WITH_SESSION
	ExpireWithConnection ExpiryPolicy = C.PN_EXPIRE_WITH_CONNECTION
	ExpireNever          ExpiryPolicy = C.PN_EXPIRE_NEVER

func (ExpiryPolicy) String

func (e ExpiryPolicy) String() string

type Injecter

type Injecter interface {
	// Inject a function into the engine goroutine.
	// f() will be called in the same goroutine as event handlers, so it can safely
	// use values belonging to event handlers without synchronization. f() should
	// not block, no further events or injected functions can be processed until
	// f() returns.
	// Returns a non-nil error if the function could not be injected and will
	// never be called. Otherwise the function will eventually be called.
	// Note that proton values (Link, Session, Connection etc.) that existed when
	// Inject(f) was called may have become invalid by the time f() is executed.
	// Handlers should handle keep track of Closed events to ensure proton values
	// are not used after they become invalid. One technique is to have map from
	// proton values to application values. Check that the map has the correct
	// proton/application value pair at the start of the injected function and
	// delete the value from the map when handling a Closed event.
	Inject(f func()) error

	// InjectWait is like Inject but does not return till f() has completed.
	// If f() cannot be injected it returns the error from Inject(), otherwise
	// it returns the error from f()
	InjectWait(f func() error) error

Injecter allows functions to be "injected" into the event-processing loop, to be called in the same goroutine as event handlers.

type Link struct {
	// contains filtered or unexported fields

func (Link) Advance

func (l Link) Advance() bool

func (Link) Available

func (l Link) Available() int

func (Link) CPtr

func (l Link) CPtr() unsafe.Pointer

func (Link) Close

func (l Link) Close()

func (Link) Condition

func (l Link) Condition() Condition

func (Link) Connection

func (l Link) Connection() Connection

func (Link) Credit

func (l Link) Credit() int

func (Link) Current

func (l Link) Current() Delivery

func (Link) Delivery

func (l Link) Delivery(tag string) Delivery

func (Link) Detach

func (l Link) Detach()

func (Link) Drain

func (l Link) Drain(credit int)

func (Link) Drained

func (l Link) Drained() int

func (Link) Draining

func (l Link) Draining() bool

func (Link) Error

func (l Link) Error() error

func (Link) Flow

func (l Link) Flow(credit int)

func (Link) Free

func (l Link) Free()

func (Link) IsDrain

func (l Link) IsDrain() bool

IsDrain calls pn_link_get_drain(), it conflicts with pn_link_drain() under the normal mapping.

func (Link) IsNil

func (l Link) IsNil() bool

func (Link) IsReceiver

func (l Link) IsReceiver() bool

func (Link) IsSender

func (l Link) IsSender() bool

func (Link) MaxMessageSize

func (l Link) MaxMessageSize() uint64

func (Link) Name

func (l Link) Name() string

func (Link) Next

func (l Link) Next(state State) Link

func (Link) Offered

func (l Link) Offered(credit int)

func (Link) Open

func (l Link) Open()

func (Link) Queued

func (l Link) Queued() int

func (Link) RcvSettleMode

func (l Link) RcvSettleMode() RcvSettleMode

func (Link) Recv

func (l Link) Recv(buf []byte) int

func (Link) RemoteCondition

func (l Link) RemoteCondition() Condition

func (Link) RemoteCredit

func (l Link) RemoteCredit() int

func (Link) RemoteMaxMessageSize

func (l Link) RemoteMaxMessageSize() uint64

func (Link) RemoteRcvSettleMode

func (l Link) RemoteRcvSettleMode() RcvSettleMode

func (Link) RemoteSndSettleMode

func (l Link) RemoteSndSettleMode() SndSettleMode

func (Link) RemoteSource

func (l Link) RemoteSource() Terminus

func (Link) RemoteTarget

func (l Link) RemoteTarget() Terminus

func (Link) Send

func (link Link) Send(m amqp.Message) (Delivery, error)

Send sends a amqp.Message over a Link. Returns a Delivery that can be use to determine the outcome of the message.

func (Link) SendBytes

func (l Link) SendBytes(bytes []byte) int

func (Link) SendMessageBytes

func (link Link) SendMessageBytes(bytes []byte) (Delivery, error)

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.

func (Link) Session

func (l Link) Session() Session

func (Link) SetDrain

func (l Link) SetDrain(drain bool)

func (Link) SetMaxMessageSize

func (l Link) SetMaxMessageSize(size uint64)

func (Link) SetRcvSettleMode

func (l Link) SetRcvSettleMode(mode RcvSettleMode)

func (Link) SetSndSettleMode

func (l Link) SetSndSettleMode(mode SndSettleMode)

func (Link) SndSettleMode

func (l Link) SndSettleMode() SndSettleMode

func (Link) Source

func (l Link) Source() Terminus

func (Link) State

func (l Link) State() State

func (Link) String

func (l Link) String() string

Human-readable link description including name, source, target and direction.

func (Link) Target

func (l Link) Target() Terminus

func (Link) Type

func (l Link) Type() string

func (Link) Unsettled

func (l Link) Unsettled() int

type MessagingAdapter

type MessagingAdapter struct {

	// AutoSettle (default true) automatically pre-settle outgoing messages.
	AutoSettle bool
	// AutoAccept (default true) automatically accept and settle incoming messages
	// if they are not settled by the delegate.
	AutoAccept bool
	// AutoOpen (default true) automatically open remotely opened endpoints.
	AutoOpen bool
	// Prefetch (default 10) initial credit to issue for incoming links.
	Prefetch int
	// PeerCloseIsError (default false) if true a close by the peer will be treated as an error.
	PeerCloseError bool
	// contains filtered or unexported fields

MessagingAdapter implements a EventHandler and delegates to a MessagingHandler. You can modify the exported fields before you pass the MessagingAdapter to a Engine.

func NewMessagingAdapter

func NewMessagingAdapter(h MessagingHandler) *MessagingAdapter

func (*MessagingAdapter) HandleEvent

func (d *MessagingAdapter) HandleEvent(e Event)

Handle a proton event by passing the corresponding MessagingEvent(s) to the MessagingHandler.

type MessagingEvent

type MessagingEvent int

MessagingEvent provides a set of events that are easier to work with than the core events defined by EventType

There are 3 types of "endpoint": Connection, Session and Link. For each endpoint there are 5 events: Opening, Opened, Closing, Closed and Error.

The meaning of these events is as follows:

Opening: The remote end opened, the local end will open automatically.

Opened: Both ends are open, regardless of which end opened first.

Closing: The remote end closed without error, the local end will close automatically.

Error: The remote end closed with an error, the local end will close automatically.

Closed: Both ends are closed, regardless of which end closed first or if there was an error. No further events will be received for the endpoint.

const (
	// The event loop starts.
	MStart MessagingEvent = iota
	// The peer closes the connection with an error condition.
	// The peer closes the session with an error condition.
	// The peer closes the link with an error condition.
	// The peer Initiates the opening of the connection.
	// The peer initiates the opening of the session.
	// The peer initiates the opening of the link.
	// The connection is opened.
	// The session is opened.
	// The link is opened.
	// The peer initiates the closing of the connection.
	// The peer initiates the closing of the session.
	// The peer initiates the closing of the link.
	// Both ends of the connection are closed.
	// Both ends of the session are closed.
	// Both ends of the link are closed.
	// The sender link has credit and messages can
	// therefore be transferred.
	// The remote peer accepts an outgoing message.
	// The remote peer rejects an outgoing message.
	// The peer releases an outgoing message. Note that this may be in response to
	// either the RELEASE or MODIFIED state as defined by the AMQP specification.
	// The peer has settled the outgoing message. This is the point at which it
	// should never be re-transmitted.
	// A message is received. Call Event.Delivery().Message() to decode as an amqp.Message.
	// To manage the outcome of this messages (e.g. to accept or reject the message)
	// use Event.Delivery().
	// A network connection was disconnected.

func (MessagingEvent) String

func (t MessagingEvent) String() string

type MessagingHandler

type MessagingHandler interface {
	// HandleMessagingEvent is called with  MessagingEvent.
	// Typically HandleEvent() is implemented as a switch on e.Type()
	HandleMessagingEvent(MessagingEvent, Event)

MessagingHandler provides an alternative interface to EventHandler. it is easier to use for most applications that send and receive messages.

Implement this interface and then wrap your value with a MessagingHandlerDelegator. MessagingHandlerDelegator implements EventHandler and can be registered with a Engine.

type PnErrorCode

type PnErrorCode int

func (PnErrorCode) String

func (e PnErrorCode) String() string

type RcvSettleMode

type RcvSettleMode C.pn_rcv_settle_mode_t
const (
	RcvFirst  RcvSettleMode = C.PN_RCV_FIRST
	RcvSecond RcvSettleMode = C.PN_RCV_SECOND

func (RcvSettleMode) String

func (e RcvSettleMode) String() string

type SASL

type SASL struct {
	// contains filtered or unexported fields

func (SASL) AllowInsecureMechs

func (s SASL) AllowInsecureMechs() bool

func (SASL) AllowedMechs

func (s SASL) AllowedMechs(mechs string)

func (SASL) CPtr

func (s SASL) CPtr() unsafe.Pointer

func (SASL) ConfigName

func (s SASL) ConfigName(name string)

func (SASL) ConfigPath

func (s SASL) ConfigPath(path string)

func (SASL) Done

func (s SASL) Done(outcome SASLOutcome)

func (SASL) IsNil

func (s SASL) IsNil() bool

func (SASL) Mech

func (s SASL) Mech() string

func (SASL) Outcome

func (s SASL) Outcome() SASLOutcome

func (SASL) SetAllowInsecureMechs

func (s SASL) SetAllowInsecureMechs(insecure bool)

func (SASL) User

func (s SASL) User() string

type SASLOutcome

type SASLOutcome C.pn_sasl_outcome_t

func (SASLOutcome) String

func (e SASLOutcome) String() string

type Session

type Session struct {
	// contains filtered or unexported fields

func (Session) CPtr

func (s Session) CPtr() unsafe.Pointer

func (Session) Close

func (s Session) Close()

func (Session) Condition

func (s Session) Condition() Condition

func (Session) Connection

func (s Session) Connection() Connection

func (Session) Error

func (s Session) Error() error

func (Session) Free

func (s Session) Free()

func (Session) IncomingBytes

func (s Session) IncomingBytes() uint

func (Session) IncomingCapacity

func (s Session) IncomingCapacity() uint

func (Session) IsNil

func (s Session) IsNil() bool

func (Session) Next

func (s Session) Next(state State) Session

func (Session) Open

func (s Session) Open()

func (Session) OutgoingBytes

func (s Session) OutgoingBytes() uint

func (Session) OutgoingWindow

func (s Session) OutgoingWindow() uint

func (Session) Receiver

func (s Session) Receiver(name string) Link

func (Session) RemoteCondition

func (s Session) RemoteCondition() Condition

func (Session) Sender

func (s Session) Sender(name string) Link

func (Session) SetIncomingCapacity

func (s Session) SetIncomingCapacity(capacity uint)

func (Session) SetOutgoingWindow

func (s Session) SetOutgoingWindow(window uint)

func (Session) State

func (s Session) State() State

func (Session) String

func (s Session) String() string

func (Session) Type

func (s Session) Type() string

type SndSettleMode

type SndSettleMode C.pn_snd_settle_mode_t
const (
	SndUnsettled SndSettleMode = C.PN_SND_UNSETTLED
	SndSettled   SndSettleMode = C.PN_SND_SETTLED
	SndMixed     SndSettleMode = C.PN_SND_MIXED

func (SndSettleMode) String

func (e SndSettleMode) String() string

type State

type State byte

State holds the state flags for an AMQP endpoint.

func (State) Has

func (s State) Has(bits State) bool

Has is True if bits & state is non 0.

func (State) Local

func (s State) Local() State

Return a State containing just the local flags

func (State) LocalActive

func (s State) LocalActive() bool

func (State) LocalClosed

func (s State) LocalClosed() bool

func (State) LocalUninit

func (s State) LocalUninit() bool

func (State) Remote

func (s State) Remote() State

Return a State containing just the remote flags

func (State) RemoteActive

func (s State) RemoteActive() bool

func (State) RemoteClosed

func (s State) RemoteClosed() bool

func (State) RemoteUninit

func (s State) RemoteUninit() bool

type Terminus

type Terminus struct {
	// contains filtered or unexported fields

func (Terminus) Address

func (t Terminus) Address() string

func (Terminus) CPtr

func (t Terminus) CPtr() unsafe.Pointer

func (Terminus) Capabilities

func (t Terminus) Capabilities() Data

func (Terminus) Copy

func (t Terminus) Copy(src Terminus) int

func (Terminus) Durability

func (t Terminus) Durability() Durability

func (Terminus) ExpiryPolicy

func (t Terminus) ExpiryPolicy() ExpiryPolicy

func (Terminus) Filter

func (t Terminus) Filter() Data

func (Terminus) IsDynamic

func (t Terminus) IsDynamic() bool

func (Terminus) IsNil

func (t Terminus) IsNil() bool

func (Terminus) Outcomes

func (t Terminus) Outcomes() Data

func (Terminus) Properties

func (t Terminus) Properties() Data

func (Terminus) SetAddress

func (t Terminus) SetAddress(address string) int

func (Terminus) SetDistributionMode

func (t Terminus) SetDistributionMode(mode DistributionMode) int

func (Terminus) SetDurability

func (t Terminus) SetDurability(durability Durability) int

func (Terminus) SetDynamic

func (t Terminus) SetDynamic(dynamic bool) int

func (Terminus) SetExpiryPolicy

func (t Terminus) SetExpiryPolicy(policy ExpiryPolicy) int

func (Terminus) SetTimeout

func (t Terminus) SetTimeout(timeout time.Duration) int

func (Terminus) SetType

func (t Terminus) SetType(type_ TerminusType) int

func (Terminus) Timeout

func (t Terminus) Timeout() time.Duration

func (Terminus) Type

func (t Terminus) Type() TerminusType

type TerminusType

type TerminusType C.pn_terminus_type_t
const (
	Unspecified TerminusType = C.PN_UNSPECIFIED
	Source      TerminusType = C.PN_SOURCE
	Target      TerminusType = C.PN_TARGET
	Coordinator TerminusType = C.PN_COORDINATOR

func (TerminusType) String

func (e TerminusType) String() string

type Transport

type Transport struct {
	// contains filtered or unexported fields

func (Transport) Bind

func (t Transport) Bind(connection Connection) int

func (Transport) CPtr

func (t Transport) CPtr() unsafe.Pointer

func (Transport) Capacity

func (t Transport) Capacity() int

func (Transport) ChannelMax

func (t Transport) ChannelMax() uint32

func (Transport) CloseHead

func (t Transport) CloseHead() int

func (Transport) CloseTail

func (t Transport) CloseTail() int

func (Transport) Closed

func (t Transport) Closed() bool

func (Transport) Condition

func (t Transport) Condition() Condition

func (Transport) Connection

func (t Transport) Connection() Connection

func (Transport) Error

func (t Transport) Error() error

func (Transport) Free

func (t Transport) Free()

func (Transport) Head

func (t Transport) Head() unsafe.Pointer

Special treatment for Transport.Head, return value is unsafe.Pointer not string

func (Transport) IdleTimeout

func (t Transport) IdleTimeout() time.Duration

func (Transport) Input

func (t Transport) Input(bytes string, available uint) int

func (Transport) IsAuthenticated

func (t Transport) IsAuthenticated() bool

func (Transport) IsEncrypted

func (t Transport) IsEncrypted() bool

func (Transport) IsNil

func (t Transport) IsNil() bool

func (Transport) Log

func (t Transport) Log(message string)

func (Transport) MaxFrame

func (t Transport) MaxFrame() uint16

func (Transport) Output

func (t Transport) Output(bytes string, size uint) int

func (Transport) Peek

func (t Transport) Peek(dst string, size uint) int

func (Transport) Pending

func (t Transport) Pending() int

func (Transport) Pop

func (t Transport) Pop(size uint)

func (Transport) Process

func (t Transport) Process(size uint) int

func (Transport) Push

func (t Transport) Push(bytes []byte) int

Special treatment for Transport.Push, takes []byte instead of char*, size

func (Transport) Quiesced

func (t Transport) Quiesced() bool

func (Transport) RemoteChannelMax

func (t Transport) RemoteChannelMax() uint32

func (Transport) RemoteIdleTimeout

func (t Transport) RemoteIdleTimeout() time.Duration

func (Transport) RemoteMaxFrame

func (t Transport) RemoteMaxFrame() uint16

func (Transport) RequireAuth

func (t Transport) RequireAuth(required bool)

func (Transport) RequireEncryption

func (t Transport) RequireEncryption(required bool)

func (Transport) SASL

func (t Transport) SASL() SASL

Get the SASL object for the transport.

func (Transport) SetChannelMax

func (t Transport) SetChannelMax(channel_max uint32) int

func (Transport) SetIdleTimeout

func (t Transport) SetIdleTimeout(timeout time.Duration)

func (Transport) SetMaxFrame

func (t Transport) SetMaxFrame(size uint16)

func (Transport) SetServer

func (t Transport) SetServer()

func (Transport) String

func (t Transport) String() string

func (Transport) Tail

func (t Transport) Tail() unsafe.Pointer

Special treatment for Transport.Tail, return value is unsafe.Pointer not string

func (Transport) Tick

func (t Transport) Tick(now int64) int64

func (Transport) Unbind

func (t Transport) Unbind() int

func (Transport) User

func (t Transport) User() string

type UUID

type UUID [16]byte

UUID is a 16-byte Universally Unique Identifier

func UUID4

func UUID4() UUID

UUID4 returns a randomly-generated (version 4) UUID, as per RFC4122

func (UUID) String

func (u UUID) String() string

String gives a UUID in standard string format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL