package main

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/tiptok/gocomm/config"
	"github.com/tiptok/gocomm/pkg/cache"
	"github.com/tiptok/gocomm/pkg/log"
	"github.com/tiptok/gocomm/pkg/redis"
	"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
	_ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
	_ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg"
	_ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/redis"
	_ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/port/beego"
	//logx "log"
)

func main() {
	defer func() {

	}()
	beego.BConfig.CopyRequestBody = true

	log.InitLog(config.Logger{
		Filename: constant.LOG_File,
		Level:    constant.LOG_LEVEL,
	})

	cache.InitDefault(cache.WithDefaultRedisPool(redis.GetRedisPool()), cache.WithDebugLog(true, log.DefaultLog), cache.WithDeleteChannel(fmt.Sprintf("%v_%v", constant.POSTGRESQL_DB_NAME, "delkey")))

	//log.DefaultLog = console.NewConsoleLog(config.Logger{
	//	Filename: constant.LOG_File,
	//	Level:    constant.LOG_LEVEL,
	//}, fmt.Sprintf("[%v]", constant.POSTGRESQL_DB_NAME), 3)
	//{
	//	// set up a span reporter
	//	reporter := zipkinhttp.NewReporter("http://106.52.15.41:9411/api/v2/spans")
	//	defer reporter.Close()
	//
	//	// create our local service endpoint
	//	endpoint, err := zipkin.NewEndpoint("godevp", "127.0.0.1:8080")
	//	if err != nil {
	//		log.Error("unable to create local endpoint: %+v\n", err)
	//	}
	//
	//	// initialize our tracer
	//	nativeTracer, err := zipkin.NewTracer(reporter, zipkin.WithLocalEndpoint(endpoint))
	//	if err != nil {
	//		log.Error("unable to create tracer: %+v\n", err)
	//	}
	//
	//	// use zipkin-go-opentracing to wrap our tracer
	//	tracer := zipkinot.Wrap(nativeTracer)
	//
	//	// optionally set as Global OpenTracing tracer instance
	//	opentracing.SetGlobalTracer(tracer)
	//}
	log.Debug(constant.REDIS_HOST, constant.REDIS_PORT)

	//go message.RunConsumer()
	//go message.RunPublish()

	beego.Run()
}