Exemple #1
0
// Producer creates a Magi instance that acts as a producer
func Producer(config *cluster.DisqueClusterConfig) (*Magi, error) {
	dqCluster, err := cluster.NewDisqueCluster(config)
	if err != nil {
		return nil, err
	}
	producer := &Magi{
		APIVersion:   MagiAPIVersion,
		dqCluster:    dqCluster,
		isProcessing: false,
	}
	return producer, nil
}
Exemple #2
0
// Consumer creates a Magi instance that acts as a consumer
func Consumer(dqConfig *cluster.DisqueClusterConfig, rConfig *cluster.RedisClusterConfig) (*Magi, error) {
	dqCluster, err := cluster.NewDisqueCluster(dqConfig)
	if err != nil {
		return nil, err
	}
	rCluster := cluster.NewRedisCluster(rConfig)
	consumer := &Magi{
		APIVersion:     MagiAPIVersion,
		dqCluster:      dqCluster,
		rCluster:       rCluster,
		isProcessing:   false,
		processors:     make(map[string]*Processor),
		processControl: make(chan string, 1),
	}
	return consumer, nil
}