Documentation ¶
Index ¶
- Constants
- func NewPublishingMessageFromRPC(rpcId, responseTo string) *amqp.Publishing
- type AmqpWriter
- type Broker
- func (b *Broker) Close()
- func (b *Broker) CreatePublisherFunc(exchange string, routingKey string) func(msg amqp.Publishing) error
- func (b *Broker) CreateRPCClient(exchange string, id string) (*RPCClient, error)
- func (b *Broker) CreateReader(p *ConsumingParam) (io.Reader, error)
- func (b *Broker) CreateWriter(exchange, key string) io.Writer
- func (b *Broker) DoConfigure(handlers ...BrokerConfigHandler)
- func (b *Broker) GetAuthBrokerConfigHandlers() []BrokerConfigHandler
- func (b *Broker) GetPublisher() *Publisher
- func (b *Broker) IsServing() bool
- func (b *Broker) RunBackground() error
- func (b *Broker) Serve()
- type BrokerConfigHandler
- func BeforeChannelExit(c ChannelHandler) BrokerConfigHandler
- func BeforeConnectionExit(c ConnectionHandler) BrokerConfigHandler
- func HookAfterChannelCreated(c ChannelHandler) BrokerConfigHandler
- func HookAfterConnectionCreated(c ConnectionHandler) BrokerConfigHandler
- func HookAfterQueueAndExchangeDeclaring(c ChannelHandler) BrokerConfigHandler
- func RPCClientConfig(exchange, id string, cb func(requestId string, msg *amqp.Delivery)) BrokerConfigHandler
- func WithAMQPUrl(url string) BrokerConfigHandler
- func WithConsumingParam(p *ConsumingParam) BrokerConfigHandler
- func WithDialConfig(c amqp.Config) BrokerConfigHandler
- func WithExchangeBind(p *ExchangeBindingParam) BrokerConfigHandler
- func WithExchangeDeclare(p *ExchangeDeclaringParam) BrokerConfigHandler
- func WithQueueBind(p *QueueBindingParam) BrokerConfigHandler
- func WithQueueDeclare(p *QueueDeclaringParam) BrokerConfigHandler
- func WithQueueDeclarePassive(p *QueueDeclaringParam) BrokerConfigHandler
- type ChannelHandler
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) GetPublisher() *Publisher
- func (c *Connection) LocalAddr() net.Addr
- func (c *Connection) Read(b []byte) (n int, err error)
- func (c *Connection) RemoteAddr() net.Addr
- func (c *Connection) SetDeadline(t time.Time) error
- func (c *Connection) SetReadDeadline(t time.Time) error
- func (c *Connection) SetWriteDeadline(t time.Time) error
- func (c *Connection) Write(b []byte) (n int, err error)
- type ConnectionAddr
- type ConnectionFrame
- type ConnectionHandler
- type ConsumingParam
- type ExchangeBindingParam
- type ExchangeDeclaringParam
- type Listener
- type Publisher
- type QueueBindingParam
- type QueueDeclaringParam
- type RPCClient
- func (r *RPCClient) Call(ctx context.Context, f, node string, req interface{}) ([]byte, error)
- func (r *RPCClient) Connect() error
- func (r *RPCClient) GetPublisher() *Publisher
- func (r *RPCClient) GetRequestSentTimeout() time.Duration
- func (r *RPCClient) SetRequestSentTimeout(duration time.Duration)
- type RPCDescription
- type RPCServer
- func (r *RPCServer) DoConfigure(options ...BrokerConfigHandler)
- func (r *RPCServer) GetBroker() *Broker
- func (r *RPCServer) GetRPCClient(id string) (*RPCClient, error)
- func (r *RPCServer) IsServing() bool
- func (r *RPCServer) RegisterService(funcName string, ...)
- func (r *RPCServer) RegisterServices(funcNames []string, ...)
- func (r *RPCServer) RunBackground() error
- func (r *RPCServer) Serve()
- type RPCSpec
Constants ¶
View Source
const ( RPC_MessageType_Request = "request" RPC_MessageType_Cancel = "cancel" RPC_MessageType_Response = "response" RPC_MessageType_Error = "error" RPC_MessageType_RequestReceived = "req-recv" )
Variables ¶
This section is empty.
Functions ¶
func NewPublishingMessageFromRPC ¶
func NewPublishingMessageFromRPC(rpcId, responseTo string) *amqp.Publishing
Types ¶
type AmqpWriter ¶
func NewAmqpWriter ¶
func NewAmqpWriter(c *amqp.Channel, exchange, key string) *AmqpWriter
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
func NewBroker ¶
func NewBroker(ctx context.Context, options ...BrokerConfigHandler) (*Broker, error)
func (*Broker) CreatePublisherFunc ¶
func (*Broker) CreateRPCClient ¶
func (*Broker) CreateReader ¶
func (b *Broker) CreateReader(p *ConsumingParam) (io.Reader, error)
func (*Broker) DoConfigure ¶
func (b *Broker) DoConfigure(handlers ...BrokerConfigHandler)
func (*Broker) GetAuthBrokerConfigHandlers ¶
func (b *Broker) GetAuthBrokerConfigHandlers() []BrokerConfigHandler
func (*Broker) GetPublisher ¶
func (*Broker) RunBackground ¶
type BrokerConfigHandler ¶
type BrokerConfigHandler func(b *Broker)
func BeforeChannelExit ¶
func BeforeChannelExit(c ChannelHandler) BrokerConfigHandler
func BeforeConnectionExit ¶
func BeforeConnectionExit(c ConnectionHandler) BrokerConfigHandler
func HookAfterChannelCreated ¶
func HookAfterChannelCreated(c ChannelHandler) BrokerConfigHandler
func HookAfterConnectionCreated ¶
func HookAfterConnectionCreated(c ConnectionHandler) BrokerConfigHandler
func HookAfterQueueAndExchangeDeclaring ¶
func HookAfterQueueAndExchangeDeclaring(c ChannelHandler) BrokerConfigHandler
func RPCClientConfig ¶
func RPCClientConfig(exchange, id string, cb func(requestId string, msg *amqp.Delivery)) BrokerConfigHandler
func WithAMQPUrl ¶
func WithAMQPUrl(url string) BrokerConfigHandler
func WithConsumingParam ¶
func WithConsumingParam(p *ConsumingParam) BrokerConfigHandler
func WithDialConfig ¶
func WithDialConfig(c amqp.Config) BrokerConfigHandler
func WithExchangeBind ¶
func WithExchangeBind(p *ExchangeBindingParam) BrokerConfigHandler
func WithExchangeDeclare ¶
func WithExchangeDeclare(p *ExchangeDeclaringParam) BrokerConfigHandler
func WithQueueBind ¶
func WithQueueBind(p *QueueBindingParam) BrokerConfigHandler
func WithQueueDeclare ¶
func WithQueueDeclare(p *QueueDeclaringParam) BrokerConfigHandler
func WithQueueDeclarePassive ¶
func WithQueueDeclarePassive(p *QueueDeclaringParam) BrokerConfigHandler
type Connection ¶
client connection
func NewConnection ¶
func NewConnection(local, remote string, ctx context.Context, options ...BrokerConfigHandler) (*Connection, error)
func NewConnectionWithBroker ¶
func NewConnectionWithBroker(local, remote string, broker *Broker) (*Connection, error)
func (*Connection) Close ¶
func (c *Connection) Close() error
func (*Connection) GetPublisher ¶
func (c *Connection) GetPublisher() *Publisher
func (*Connection) LocalAddr ¶
func (c *Connection) LocalAddr() net.Addr
func (*Connection) RemoteAddr ¶
func (c *Connection) RemoteAddr() net.Addr
func (*Connection) SetDeadline ¶
func (c *Connection) SetDeadline(t time.Time) error
func (*Connection) SetReadDeadline ¶
func (c *Connection) SetReadDeadline(t time.Time) error
func (*Connection) SetWriteDeadline ¶
func (c *Connection) SetWriteDeadline(t time.Time) error
type ConnectionAddr ¶
初始化网络地址 API
func (*ConnectionAddr) Network ¶
func (a *ConnectionAddr) Network() string
func (*ConnectionAddr) String ¶
func (a *ConnectionAddr) String() string
type ConnectionFrame ¶
type ConnectionFrame struct { From string `json:"from"` Buf []byte `json:"buf"` // 服务端和客户端都应该处理,客户端收到这个,就直接取消全部上下文 // 服务端收到这个,马上关闭文件,删除缓存 Closed bool `json:"closed"` // 只有服务端处理这个,创建会话 First bool `json:"first"` }
Connection Models
type ConnectionHandler ¶
type ConnectionHandler func(broker *Broker, a *amqp.Connection) error
type ConsumingParam ¶
type ExchangeBindingParam ¶
type ExchangeDeclaringParam ¶
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
func (*Publisher) PublishTo ¶
func (p *Publisher) PublishTo(exchange, routingKey string, msg amqp.Publishing) error
func (*Publisher) PublishToQueue ¶
func (p *Publisher) PublishToQueue(queue string, msg amqp.Publishing) error
type QueueBindingParam ¶
type QueueDeclaringParam ¶
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
func NewRPCClient ¶
func NewRPCClientWithBroker ¶
func (*RPCClient) GetPublisher ¶
func (*RPCClient) GetRequestSentTimeout ¶
func (*RPCClient) SetRequestSentTimeout ¶
type RPCDescription ¶
type RPCServer ¶
func NewRPCServer ¶
func (*RPCServer) DoConfigure ¶
func (r *RPCServer) DoConfigure(options ...BrokerConfigHandler)
func (*RPCServer) GetRPCClient ¶
一定用在 Serve 之前
func (*RPCServer) RegisterService ¶
func (*RPCServer) RegisterServices ¶
func (*RPCServer) RunBackground ¶
type RPCSpec ¶
type RPCSpec struct {
// contains filtered or unexported fields
}
func NewRPCSpec ¶
func NewRPCSpec() *RPCSpec
func (*RPCSpec) Register ¶
func (r *RPCSpec) Register(f string, desc *RPCDescription)
Click to show internal directories.
Click to hide internal directories.