package main

import (
	"flag"
	"sparrow/pkg/rpcs"
	"sparrow/pkg/server"
	"sparrow/services/scene-access/internal/service"
)

const (
	flagRabbitHost    = "rabbithost"
	defaultRabbitHost = "amqp://guest:guest@localhost:5672/"
)

var (
	confRabbitHost = flag.String(flagRabbitHost, defaultRabbitHost, "rabbitmq host address, amqp://user:password@ip:port/")
)

func main() {
	// init server
	err := server.Init(rpcs.SceneAccessServiceName)
	if err != nil {
		server.Log.Fatal(err)
		return
	}
	scene := service.NewSceneService(*confRabbitHost)

	err = server.RegisterRPCHandler(scene)
	if err != nil {
		return
	}

	// start to run
	err = server.Run()
	if err != nil {
		server.Log.Fatal(err)
	}
}
