Esempio n. 1
0
// Initialize the service using default values
func init() {
	Adapter = &Redis{
		endpoint:          "localhost:3679",
		password:          "",
		db:                0,
		connectionTimeout: time.Second * 1,
		logger:            log.New(ioutil.Discard, "", log.LstdFlags),
		dialPolicy:        dial.ExpBackoff(10, time.Millisecond),
		closeNotifier:     adapters.NewNotifier(),
	}
}
Esempio n. 2
0
	"sync"

	"time"

	"io/ioutil"

	"github.com/achilleasa/usrv-service-adapters"
	"github.com/achilleasa/usrv-service-adapters/dial"
	amqpDriver "github.com/streadway/amqp"
)

// Adapter is a singleton instance of a amqp service
var Adapter *Amqp = &Amqp{
	endpoint:      "localhost:55672",
	logger:        log.New(ioutil.Discard, "", log.LstdFlags),
	dialPolicy:    dial.ExpBackoff(10, time.Millisecond),
	closeNotifier: adapters.NewNotifier(),
}

type Amqp struct {

	// The amqp endpoint to connect to. Set manually by the user or discovered
	// by a configuration service (e.g. etcd)
	endpoint string

	// A logger for service events.
	logger *log.Logger

	// A mutex protecting dial attempts.
	sync.Mutex