예제 #1
0
func setupCommonIo() {
	cfg := common_io.Config{}

	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Producer
	 */
	producer, err = common_io.NewProducer(cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Consumer
	 */
	consumer = common_io.NewConsumer(cfg)

	/*
	*	Topics
	 */
	// users (patient, medic, pharmaceutic)
	consumer.HandleTopic("send_mail", mailer.SendMail)

	if err = consumer.StartListening(); err != nil {
		log.Fatal(err)
	}

}
예제 #2
0
func TestSendMail(t *testing.T) {
	cfg := common_io.Config{}
	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	producer, err := common_io.NewProducer(cfg)
	if err != nil {
		t.Error(err)
	}

	defer producer.TearDown()

	m := mailer.Mail{
		To:      []string{"*****@*****.**"},
		Subject: "Test from Asvins server",
		Body:    "Test Message from Asvins Servers.\n -- Asvins Team",
	}

	b, err := json.Marshal(&m)
	if err != nil {
		fmt.Println(err)
		t.Error(err)
	}

	producer.Publish("send_mail", b)
	fmt.Println(">>Send_mail message 1 published!")
}
예제 #3
0
func setupCommonIo() {
	cfg := common_io.Config{}

	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Producer
	 */
	producer, err = common_io.NewProducer(cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Consumer
	 */
	consumer = common_io.NewConsumer(cfg)

	/*
	*	Topics
	 */
	consumer.HandleTopic("user_created", handleUserCreated)
	consumer.HandleTopic("treatment_created", handleTreatmentCreated)

	if err = consumer.StartListening(); err != nil {
		log.Fatal(err)
	}
}
예제 #4
0
파일: common_io.go 프로젝트: asvins/core
func setupCommonIo() {
	cfg := common_io.Config{}

	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Producer
	 */
	producer, err = common_io.NewProducer(cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Consumer
	 */
	consumer = common_io.NewConsumer(cfg)

	/*
	*	Topics
	 */
	consumer.HandleTopic("user_created", handleUserCreated)
	consumer.HandleTopic("patient_updated", handlePatientUpdated)
	consumer.HandleTopic("box_created", handleBoxCreated)
	consumer.HandleTopic("subscription_updated", handleSubscriptionUpdated)
	consumer.HandleTopic("activate_treatments", handleActivateTreatments)
	consumer.HandleTopic("treatment_approved", handleTreatmentApproved)

	if err = consumer.StartListening(); err != nil {
		log.Fatal(err)
	}
}
예제 #5
0
func setupCommonIo() {
	cfg := common_io.Config{}

	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Producer
	 */
	producer, err = common_io.NewProducer(cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Consumer
	 */
	consumer = common_io.NewConsumer(cfg)
	consumer.HandleTopic("product_created", handleProductCreated)

	if err = consumer.StartListening(); err != nil {
		log.Fatal(err.Error())
	}
}
예제 #6
0
func setupCommonIo() {
	cfg := common_io.Config{}

	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Producer
	 */
	producer, err = common_io.NewProducer(cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Consumer
	 */
	consumer = common_io.NewConsumer(cfg)

	/*
	*	topics
	 */
	consumer.HandleTopic("treatment_created", treatmentCreatedHandler)
	consumer.HandleTopic("treatment_updated", treatmentCreatedHandler)
	consumer.HandleTopic("subscription_paid", subscriptionPaidHandler)

	if err = consumer.StartListening(); err != nil {
		log.Fatal(err)
	}
}
예제 #7
0
func initDatabase() {
	err := config.Load("warehouse_config.gcfg", ServerConfig)
	if err != nil {
		log.Fatal(err)
	}

	DatabaseConfig := postgres.NewConfig(ServerConfig.Database.User, ServerConfig.Database.DbName, ServerConfig.Database.SSLMode)
	testdb = postgres.GetDatabase(DatabaseConfig)
}
예제 #8
0
func init() {
	fmt.Println("[INFO] Function init called")
	c = Config{}
	err := config.Load("common_io_config.gcfg", &c)
	if err != nil {
		log.Fatal("[ERROR] Unable to load configs: ", err)
		return
	}

	if c.ModuleName.Value == "" {
		log.Fatal("[ERROR] Module name can't be empty")
		return
	}

	kafka_up = os.Getenv("KAFKA_UP")
}
예제 #9
0
파일: server.go 프로젝트: asvins/warehouse
// function that will run before main
func init() {
	fmt.Println("[INFO] Initializing server")
	err := config.Load("warehouse_config.gcfg", ServerConfig)
	if err != nil {
		log.Fatal(err)
	}

	DatabaseConfig := postgres.NewConfig(ServerConfig.Database.User, ServerConfig.Database.DbName, ServerConfig.Database.SSLMode)
	db = postgres.GetDatabase(DatabaseConfig)
	fmt.Println("[INFO] Initialization Done!")

	/*
	*	Common io
	 */
	setupCommonIo()
}
예제 #10
0
파일: common_io.go 프로젝트: asvins/auth
func setupCommonIo() {
	cfg := common_io.Config{}

	err := config.Load("common_io_config.gcfg", &cfg)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Producer
	 */
	producer, err = common_io.NewProducer(cfg)
	if err != nil {
		log.Fatal(err)
	}

}
예제 #11
0
func init() {
	fmt.Println("[INFO] Initializing server")
	err := config.Load("subscription_config.gcfg", ServerConfig)
	if err != nil {
		log.Fatal(err)
	}

	/*
	*	Common io
	 */
	setupCommonIo()

	/*
	*	Module crons
	 */
	startPaymentVerificationCron()

	fmt.Println("[INFO] Initialization Done!")
}
예제 #12
0
func main() {

	/*
	*	Server config
	 */
	serverConf := Config{}
	err := config.Load("notification_config.gcfg", &serverConf)
	if err != nil {
		log.Fatal(err)
	}

	r := DefRoutes()

	/*
	*	Common io
	 */
	setupCommonIo()

	fmt.Println("Server running on port: ", serverConf.Server.Port)
	http.ListenAndServe(":"+serverConf.Server.Port, r)
}