Documentation
¶
Index ¶
- Constants
- func HydraAuthenticationFunc(ctx context.Context, accessToken string) (userID string, err error)
- func LoggingUnaryInterceptor(log *logrus.Entry) ...
- type AuthenticationFunc
- type Channel
- type ConnIdentifier
- type Server
- func (s *Server) Command(ctx context.Context, in *pb.CommandMessage) (*pb.CommandResponse, error)
- func (s *Server) Connect(ctx context.Context, in *pb.ConnectionRequest) (*pb.ConnectionResponse, error)
- func (s *Server) Disconnect(ctx context.Context, in *pb.DisconnectRequest) (*pb.DisconnectResponse, error)
Constants ¶
View Source
const ( IsAuthenticatedKey = "isAuthenticated" UserIDKey = "userID" )
View Source
const ( CmdMessage = "message" CmdPing = "ping" CmdSubscribe = "subscribe" CmdUnsubscribe = "unsubscribe" WelcomeMessage = `{"type": "welcome"}` ConfirmSubscriptionMessageTemplate = `{"identifier": "%s", "type": "confirm_subscription"}` RejectSubscriptionMessageTemplate = `{"identifier": "%s", "type": "reject_subscription"}` )
Variables ¶
This section is empty.
Functions ¶
func HydraAuthenticationFunc ¶
func LoggingUnaryInterceptor ¶
func LoggingUnaryInterceptor(log *logrus.Entry) func(context.Context, interface{}, *grpc.UnaryServerInfo, grpc.UnaryHandler) (interface{}, error)
LoggingUnaryInterceptor returns a gRPC unary interceptor that logs all incoming gRPC calls. It logs the method details, request, response, and any potential errors.
Types ¶
type AuthenticationFunc ¶
AuthenticationFunc is used to authenticate a user based on the provided access token.
type Channel ¶
type Channel interface { // Authorize checks if the user is authorized to subscribe to the channel, // based on the provided user ID and channel identifier. Authorize(ctx context.Context, userID string, ident map[string]string) error // GetStreams returns a list of streams that the user should be subscribed to // or unsubscribe from, based on the provided user ID and channel identifier. GetStreams(ctx context.Context, userID string, ident map[string]string) []string }
Channel represents a single communication path, supporting authorization and multiple streams subscription
type ConnIdentifier ¶
type ConnIdentifier struct {
AccessToken string
}
ConnIdentifier is used to identify a specific connection through its AccessToken.
type Server ¶
type Server struct { pb.UnimplementedRPCServer Channels map[string]Channel WithAuthentication bool AuthenticationFunc AuthenticationFunc Logger *logrus.Entry }
Server encapsulates the AnyCable RPC server functionalities.
func (*Server) Command ¶
func (s *Server) Command(ctx context.Context, in *pb.CommandMessage) (*pb.CommandResponse, error)
func (*Server) Connect ¶
func (s *Server) Connect(ctx context.Context, in *pb.ConnectionRequest) (*pb.ConnectionResponse, error)
func (*Server) Disconnect ¶
func (s *Server) Disconnect(ctx context.Context, in *pb.DisconnectRequest) (*pb.DisconnectResponse, error)
Click to show internal directories.
Click to hide internal directories.