Messaging/pkg/grpc/client.go

45 lines
1.1 KiB
Go
Raw Normal View History

2024-03-26 15:05:13 +00:00
package grpc
import (
2024-05-26 15:01:20 +00:00
pcpb "git.solsynth.dev/hydrogen/paperclip/pkg/grpc/proto"
2024-05-04 16:39:59 +00:00
idpb "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto"
2024-03-26 15:05:13 +00:00
"google.golang.org/grpc/credentials/insecure"
"github.com/spf13/viper"
"google.golang.org/grpc"
)
2024-05-26 15:01:20 +00:00
var Attachments pcpb.AttachmentsClient
func ConnectPaperclip() error {
addr := viper.GetString("paperclip.grpc_endpoint")
if conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil {
return err
} else {
Attachments = pcpb.NewAttachmentsClient(conn)
}
return nil
}
var (
Realms idpb.RealmsClient
Friendships idpb.FriendshipsClient
Notify idpb.NotifyClient
Auth idpb.AuthClient
)
2024-03-26 15:05:13 +00:00
func ConnectPassport() error {
2024-05-26 15:01:20 +00:00
addr := viper.GetString("passport.grpc_endpoint")
2024-03-26 15:05:13 +00:00
if conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil {
return err
} else {
2024-05-04 16:39:59 +00:00
Realms = idpb.NewRealmsClient(conn)
2024-04-06 06:36:36 +00:00
Friendships = idpb.NewFriendshipsClient(conn)
2024-03-26 15:05:13 +00:00
Notify = idpb.NewNotifyClient(conn)
Auth = idpb.NewAuthClient(conn)
}
return nil
}