You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
696 B

  1. package client
  2. import (
  3. "context"
  4. "google.golang.org/grpc"
  5. "github.com/chrislusf/seaweedfs/weed/pb"
  6. "github.com/chrislusf/seaweedfs/weed/security"
  7. "github.com/chrislusf/seaweedfs/weed/util"
  8. )
  9. type MessagingClient struct {
  10. bootstrapBrokers []string
  11. grpcConnection *grpc.ClientConn
  12. }
  13. func NewMessagingClient(bootstrapBrokers []string) (*MessagingClient, error) {
  14. grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.msg_client")
  15. grpcConnection, err := pb.GrpcDial(context.Background(), "localhost:17777", grpcDialOption)
  16. if err != nil {
  17. return nil, err
  18. }
  19. return &MessagingClient{
  20. bootstrapBrokers: bootstrapBrokers,
  21. grpcConnection: grpcConnection,
  22. }, nil
  23. }