Passport/pkg/server/startup.go

40 lines
625 B
Go
Raw Normal View History

2024-01-06 17:56:32 +00:00
package server
import (
"code.smartsheep.studio/hydrogen/bus/pkg/kit/publisher"
"github.com/spf13/viper"
)
const (
Hostname = "hydrogen.passport"
Namespace = "passport"
)
var C *publisher.PublisherConnection
func InitConnection(addr, id string) error {
if conn, err := publisher.NewConnection(
addr,
id,
Hostname,
Namespace,
viper.Get("credentials"),
); err != nil {
return err
} else {
C = conn
}
return nil
}
func PublishCommands(conn *publisher.PublisherConnection) error {
for k, v := range Commands {
if err := conn.PublishCommand(k, v); err != nil {
return err
}
}
return nil
}