Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewModule ¶
func NewModule(namespace string, opts ...ModuleOption) fx.Option
NewModule construct a new fx Module for mongodb, using configuration options Each mongo client will be named as <namespace>_<name> Also register a <namespace> group
Example ¶
package main
import (
"github.com/lagolibs/amqpfx"
"go.uber.org/fx"
)
func main() {
configs := make(map[string]string, 2)
configs["clienta"] = "amqp://localhost:61616"
configs["clientb"] = "amqp://127.0.0.1:61616"
fx.New(
amqpfx.NewModule("amq", amqpfx.WithURIs(configs)),
fx.Invoke(
fx.Annotate(func(client *amqpfx.Client) {},
fx.ParamTags(`name:"amq_clienta"`),
),
),
).Run()
}
Output:
Example (SingleClient) ¶
package main
import (
"github.com/lagolibs/amqpfx"
"go.uber.org/fx"
)
func main() {
configs := make(map[string]string, 2)
configs["clienta"] = "amqp://localhost:61616"
fx.New(
amqpfx.NewModule("amq", amqpfx.WithURIs(configs)),
fx.Invoke(
fx.Annotate(func(client *amqpfx.Client) {},
fx.ParamTags(`name:"amq_clienta"`),
),
),
).Run()
}
Output:
func NewSimpleModule ¶
NewSimpleModule construct a module contain single client. Does not register group namespace. The name of the mongo client is the same as the name space.
Example ¶
package main
import (
"github.com/lagolibs/amqpfx"
"go.uber.org/fx"
)
func main() {
fx.New(
amqpfx.NewSimpleModule("amq", "amqp://localhost:61616"),
fx.Invoke(
fx.Annotate(func(client *amqpfx.Client) {},
fx.ParamTags(`name:"amq"`),
),
),
).Run()
}
Output:
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶ added in v0.2.0
func NewClient(config *ClientConfig) (*Client, error)
type ClientConfig ¶ added in v0.2.0
type ClientConfig struct {
// contains filtered or unexported fields
}
func NewClientConfig ¶ added in v0.2.0
func NewClientConfig() ClientConfig
type Conn ¶
func (*Conn) NewSession ¶
type ModuleOption ¶
type ModuleOption func(conf *moduleConfig)
ModuleOption applies an option to moduleConfig
func WithURIs ¶
func WithURIs(uris map[string]string) ModuleOption
WithURIs create ModuleOption that parse a map of uris into moduleConfig. This help integrate with configuration library such as vipers
type ReceiveOption ¶
type ReceiveOption = func(conf *amqp.ReceiveOptions)
type ReceiverOption ¶
type ReceiverOption = func(conf *amqp.ReceiverOptions)
type SendOption ¶
type SendOption = func(conf *amqp.SendOptions)
type SenderOption ¶
type SenderOption = func(conf *amqp.SenderOptions)
type Session ¶
func (*Session) NewReceiver ¶
func (s *Session) NewReceiver(source string, opts ...ReceiverOption) (*Receiver, error)