Documentation ¶
Index ¶
- func RunGRPCServer(ctx context.Context, port string, db *sql.DB, log *logrus.Logger) error
- func SetupGRPCServer(tokenValidator TokenValidator, logger *logrus.Logger) *grpc.Server
- func StreamServerInterceptor(tokenValidator TokenValidator, logger *logrus.Logger) grpc.StreamServerInterceptor
- func UnaryServerInterceptor(tokenValidator TokenValidator, logger *logrus.Logger) grpc.UnaryServerInterceptor
- type AuthServer
- func (s *AuthServer) GetPublicKeyBundle(ctx context.Context, req *auth.PublicKeyBundleRequest) (*auth.PublicKeyBundleResponse, error)
- func (s *AuthServer) LoginUser(ctx context.Context, req *auth.LoginRequest) (*auth.LoginResponse, error)
- func (s *AuthServer) RefreshToken(ctx context.Context, req *auth.RefreshTokenRequest) (*auth.RefreshTokenResponse, error)
- func (s *AuthServer) RegisterUser(ctx context.Context, req *auth.RegisterRequest) (*auth.RegisterResponse, error)
- func (s *AuthServer) UploadPublicKeys(ctx context.Context, req *auth.PublicKeyUploadRequest) (*auth.PublicKeyUploadResponse, error)
- type ChatServiceServer
- type FriendsServer
- func (s *FriendsServer) AcceptFriendRequest(ctx context.Context, req *friends.AcceptFriendRequestRequest) (*friends.AcceptFriendRequestResponse, error)
- func (s *FriendsServer) DeclineFriendRequest(ctx context.Context, req *friends.DeclineFriendRequestRequest) (*friends.DeclineFriendRequestResponse, error)
- func (s *FriendsServer) GetFriendList(ctx context.Context, req *friends.GetFriendListRequest) (*friends.GetFriendListResponse, error)
- func (s *FriendsServer) GetIncomingFriendRequests(ctx context.Context, req *friends.GetIncomingFriendRequestsRequest) (*friends.GetIncomingFriendRequestsResponse, error)
- func (s *FriendsServer) GetOutgoingFriendRequests(ctx context.Context, req *friends.GetOutgoingFriendRequestsRequest) (*friends.GetOutgoingFriendRequestsResponse, error)
- func (s *FriendsServer) RemoveFriend(ctx context.Context, req *friends.RemoveFriendRequest) (*friends.RemoveFriendResponse, error)
- func (s *FriendsServer) SendFriendRequest(ctx context.Context, req *friends.SendFriendRequestRequest) (*friends.SendFriendRequestResponse, error)
- type JWTTokenValidator
- type TokenValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunGRPCServer ¶
RunGRPCServer initializes and runs the gRPC server.
func SetupGRPCServer ¶
func SetupGRPCServer(tokenValidator TokenValidator, logger *logrus.Logger) *grpc.Server
Adding the interceptors to your gRPC server configuration
func StreamServerInterceptor ¶
func StreamServerInterceptor(tokenValidator TokenValidator, logger *logrus.Logger) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new stream server interceptor for validating tokens.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(tokenValidator TokenValidator, logger *logrus.Logger) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor for validating tokens.
Types ¶
type AuthServer ¶
type AuthServer struct { auth.UnimplementedAuthServiceServer DB *sql.DB Logger *logrus.Logger AccessTokenExpiration time.Duration RefreshTokenExpiration time.Duration }
AuthServer implements the AuthService.
func NewAuthServer ¶
func NewAuthServer(db *sql.DB, logger *logrus.Logger, accessTokenExpiration, refreshTokenExpiration time.Duration) *AuthServer
NewAuthServer creates a new AuthServer with the given dependencies.
func (*AuthServer) GetPublicKeyBundle ¶
func (s *AuthServer) GetPublicKeyBundle(ctx context.Context, req *auth.PublicKeyBundleRequest) (*auth.PublicKeyBundleResponse, error)
func (*AuthServer) LoginUser ¶
func (s *AuthServer) LoginUser(ctx context.Context, req *auth.LoginRequest) (*auth.LoginResponse, error)
LoginUser handles user login requests.
func (*AuthServer) RefreshToken ¶
func (s *AuthServer) RefreshToken(ctx context.Context, req *auth.RefreshTokenRequest) (*auth.RefreshTokenResponse, error)
RefreshToken handles token refresh requests.
func (*AuthServer) RegisterUser ¶
func (s *AuthServer) RegisterUser(ctx context.Context, req *auth.RegisterRequest) (*auth.RegisterResponse, error)
RegisterUser handles user registration requests.
func (*AuthServer) UploadPublicKeys ¶
func (s *AuthServer) UploadPublicKeys(ctx context.Context, req *auth.PublicKeyUploadRequest) (*auth.PublicKeyUploadResponse, error)
Implement the server-side handler for UploadPublicKeys
type ChatServiceServer ¶
type ChatServiceServer struct { chat.UnimplementedChatServiceServer ActiveClients map[uint32]chat.ChatService_StreamMessagesServer // Map from userID to their active stream UndeliveredMessages map[uint32][]*chat.MessageResponse // Map from userID to their undelivered messages Logger *logrus.Logger // contains filtered or unexported fields }
func NewChatServiceServer ¶
func NewChatServiceServer(logger *logrus.Logger) *ChatServiceServer
func (*ChatServiceServer) IsActiveClient ¶
func (s *ChatServiceServer) IsActiveClient(userID uint32) bool
IsActiveClient checks if a user is in the ActiveClients map.
func (*ChatServiceServer) StreamMessages ¶
func (s *ChatServiceServer) StreamMessages(stream chat.ChatService_StreamMessagesServer) error
StreamMessages handles bidirectional message streaming between users.
type FriendsServer ¶
type FriendsServer struct { friends.UnimplementedFriendManagementServer DB *sql.DB Logger *logrus.Logger }
FriendsServer implements the FriendsService.
func NewFriendsServer ¶
func NewFriendsServer(db *sql.DB, logger *logrus.Logger) *FriendsServer
NewFriendsServer creates a new FriendsServer with the given dependencies.
func (*FriendsServer) AcceptFriendRequest ¶
func (s *FriendsServer) AcceptFriendRequest(ctx context.Context, req *friends.AcceptFriendRequestRequest) (*friends.AcceptFriendRequestResponse, error)
AcceptFriendRequest handles accepting a friend request.
func (*FriendsServer) DeclineFriendRequest ¶
func (s *FriendsServer) DeclineFriendRequest(ctx context.Context, req *friends.DeclineFriendRequestRequest) (*friends.DeclineFriendRequestResponse, error)
DeclineFriendRequest handles declining a friend request.
func (*FriendsServer) GetFriendList ¶
func (s *FriendsServer) GetFriendList(ctx context.Context, req *friends.GetFriendListRequest) (*friends.GetFriendListResponse, error)
GetFriendList retrieves the list of friends for the user.
func (*FriendsServer) GetIncomingFriendRequests ¶
func (s *FriendsServer) GetIncomingFriendRequests(ctx context.Context, req *friends.GetIncomingFriendRequestsRequest) (*friends.GetIncomingFriendRequestsResponse, error)
GetIncomingFriendRequests retrieves the incoming friend requests for the user.
func (*FriendsServer) GetOutgoingFriendRequests ¶
func (s *FriendsServer) GetOutgoingFriendRequests(ctx context.Context, req *friends.GetOutgoingFriendRequestsRequest) (*friends.GetOutgoingFriendRequestsResponse, error)
GetOutgoingFriendRequests retrieves the outgoing friend requests sent by the user.
func (*FriendsServer) RemoveFriend ¶
func (s *FriendsServer) RemoveFriend(ctx context.Context, req *friends.RemoveFriendRequest) (*friends.RemoveFriendResponse, error)
RemoveFriend handles removing a friend.
func (*FriendsServer) SendFriendRequest ¶
func (s *FriendsServer) SendFriendRequest(ctx context.Context, req *friends.SendFriendRequestRequest) (*friends.SendFriendRequestResponse, error)
SendFriendRequest handles sending a friend request.
type JWTTokenValidator ¶
type JWTTokenValidator struct {
// contains filtered or unexported fields
}
JWTTokenValidator is a struct that implements the TokenValidator interface using JWT.
func NewJWTTokenValidator ¶
func NewJWTTokenValidator(secretKey string) *JWTTokenValidator
NewJWTTokenValidator creates a new instance of JWTTokenValidator.
func (*JWTTokenValidator) ValidateToken ¶
func (v *JWTTokenValidator) ValidateToken(tokenString string) (string, string, error)
ValidateToken validates the JWT token and extracts the user ID and username.