-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
159908b
commit 7ab711b
Showing
13 changed files
with
97 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# goamqp-wrapper | ||
# Amqpwrapper | ||
[![CircleCI](https://circleci.com/gh/fairyhunter13/amqpwrapper/tree/master.svg?style=svg)](https://circleci.com/gh/fairyhunter13/amqpwrapper/tree/master) | ||
[![Coverage Status](https://coveralls.io/repos/github/fairyhunter13/amqpwrapper/badge.svg?branch=master)](https://coveralls.io/github/fairyhunter13/amqpwrapper?branch=master) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/fairyhunter13/amqpwrapper)](https://goreportcard.com/report/github.com/fairyhunter13/amqpwrapper) | ||
|
||
Wrapper library for streadway/amqp in golang. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package rabbitmq | ||
package amqpwrapper | ||
|
||
import "github.com/streadway/amqp" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build integration | ||
|
||
package rabbitmq | ||
package amqpwrapper | ||
|
||
import ( | ||
"errors" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Package amqpwrapper manage the connection and channel from streadway/amqp. | ||
Amqpwrapper wraps the connection and channel from streadway/amqp. | ||
This package manages auto reconnection and channel lifecycle. | ||
This package ensures two connection will be initialized for each type (producers and consumers). | ||
This has to be done because initialization of tcp connection is very costly and slowing performance greatly in production. | ||
*/ | ||
package amqpwrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package rabbitmq | ||
package amqpwrapper | ||
|
||
import "errors" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package amqpwrapper | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/streadway/amqp" | ||
) | ||
|
||
func ExampleNewManager() { | ||
_, err := NewManager("amqp://guest:guest@localhost:5672/", amqp.Config{}) | ||
if err != nil { | ||
log.Fatalf("Error in creating new connection manager: %s", err) | ||
} | ||
} | ||
|
||
func ExampleConnectionManager_CreateChannel() { | ||
manager, err := NewManager("amqp://guest:guest@localhost:5672/", amqp.Config{}) | ||
if err != nil { | ||
log.Fatalf("Error in creating new connection manager: %s", err) | ||
} | ||
prodChan, err := manager.CreateChannel(Producer) | ||
if err != nil { | ||
log.Fatalf("Error in creating new channel: %s", err) | ||
} | ||
defer prodChan.Close() | ||
} | ||
|
||
func ExampleConnectionManager_GetChannel() { | ||
manager, err := NewManager("amqp://guest:guest@localhost:5672/", amqp.Config{}) | ||
if err != nil { | ||
log.Fatalf("Error in creating new connection manager: %s", err) | ||
} | ||
prodChan, err := manager.GetChannel("Already Initialized Channel", Producer) | ||
if err != nil { | ||
log.Fatalf("Error in getting the channel: %s", err) | ||
} | ||
defer prodChan.Close() | ||
} | ||
|
||
func ExampleConnectionManager_InitChannel() { | ||
manager, err := NewManager("amqp://guest:guest@localhost:5672/", amqp.Config{}) | ||
if err != nil { | ||
log.Fatalf("Error in creating new connection manager: %s", err) | ||
} | ||
prodChan, err := manager.CreateChannel(Producer) | ||
if err != nil { | ||
log.Fatalf("Error in creating new channel: %s", err) | ||
} | ||
initChannel := func(amqpChan *amqp.Channel) (err error) { | ||
err = amqpChan.ExchangeDeclare("hello", "topic", true, false, false, false, nil) | ||
return | ||
} | ||
args := InitArgs{ | ||
Channel: prodChan, | ||
Key: "New Producer", | ||
TypeChan: Consumer, | ||
} | ||
err = manager.InitChannel(initChannel, args) | ||
if err != nil { | ||
log.Fatalf("Error in initializing the channel: %s", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build integration | ||
|
||
package rabbitmq | ||
package amqpwrapper | ||
|
||
import ( | ||
"flag" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// +build integration | ||
|
||
package rabbitmq | ||
package amqpwrapper | ||
|
||
import ( | ||
"errors" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package rabbitmq | ||
package amqpwrapper | ||
|
||
import ( | ||
"time" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters