message.go 2.4 KB
package factory

//import (
//	"fmt"
//	"github.com/linmadan/egglib-go/core/application"
//	"github.com/linmadan/egglib-go/message/publisher/kafkaMessage/sarama"
//	localMessagePublisher "github.com/linmadan/egglib-go/message/publisher/local_message"
//	localMessageReceiver "github.com/linmadan/egglib-go/message/receiver/local_message"
//	"suplus-message/pkg/constant"
//	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
//)
//
//func CreateMessagePublisher(options map[string]interface{}) (application.MessagePublisher, error) {
//	if localMessageOptions, ok := options["localMessageOptions"]; ok {
//		var storeType string
//		var storeOptions map[string]interface{}
//		if value, ok := localMessageOptions.(map[string]interface{})["storeType"]; ok {
//			storeType = value.(string)
//		} else {
//			return nil, fmt.Errorf("LocalMessagePublisher缺少参数storeType")
//		}
//		if value, ok := localMessageOptions.(map[string]interface{})["storeOptions"]; ok {
//			storeOptions = value.(map[string]interface{})
//		} else {
//			return nil, fmt.Errorf("LocalMessagePublisher缺少参数storeOptions")
//		}
//		return localMessagePublisher.NewLocalMessagePublisher(storeType, storeOptions)
//	} else {
//		return sarama.NewKafkaSaramaMessagePublisher(constant.KAFKA_HOSTS,log.Logger)
//	}
//}
//
//func CreateMessageReceiver(options map[string]interface{}) (application.MessageReceiver, error) {
//	if localMessageOptions, ok := options["localMessageOptions"]; ok {
//		var converterType string
//		if value, ok := localMessageOptions.(map[string]interface{})["converterType"]; ok {
//			converterType = value.(string)
//		} else {
//			return nil, fmt.Errorf("LocalMessageReceiver缺少参数converterType")
//		}
//		var storeType string
//		var storeOptions map[string]interface{}
//		if value, ok := localMessageOptions.(map[string]interface{})["storeType"]; ok {
//			storeType = value.(string)
//		} else {
//			return nil, fmt.Errorf("LocalMessageReceiver缺少参数storeType")
//		}
//		if value, ok := localMessageOptions.(map[string]interface{})["storeOptions"]; ok {
//			storeOptions = value.(map[string]interface{})
//		} else {
//			return nil, fmt.Errorf("LocalMessageReceiver缺少参数storeOptions")
//		}
//		return localMessageReceiver.NewLocalMessageReceiver(converterType, nil, storeType, storeOptions)
//	} else {
//		return nil, fmt.Errorf("缺少参数localMessageOptions")
//	}
//}