utils

package
v0.0.0-...-67df305 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRateLimiter

func GetRateLimiter(userID string) *rate.Limiter

GetRateLimiter returns a rate limiter for a given user ID

Types

type AwardNotification

type AwardNotification struct {
	Type     string    `json:"type"`
	TenderID uuid.UUID `json:"tender_id"`
	AwardID  uuid.UUID `json:"award_id"`
	Message  string    `json:"message"`
}

type BidNotification

type BidNotification struct {
	Type     string    `json:"type"`
	TenderID uuid.UUID `json:"tender_id"`
	BidID    uuid.UUID `json:"bid_id"`
	Price    float64   `json:"price"`
	Message  string    `json:"message"`
}

type Claims

type Claims struct {
	UserID uuid.UUID       `json:"user_id"`
	Role   models.UserRole `json:"role"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(tokenString string, secretKey []byte) (*Claims, error)

type JWTUtil

type JWTUtil struct {
	// contains filtered or unexported fields
}

func NewJWTUtil

func NewJWTUtil(secretKey string) *JWTUtil

func (*JWTUtil) GenerateToken

func (j *JWTUtil) GenerateToken(userID uuid.UUID, role models.UserRole) (string, error)

func (*JWTUtil) ParseToken

func (j *JWTUtil) ParseToken(tokenString string) (*Claims, error)

func (*JWTUtil) ValidateToken

func (j *JWTUtil) ValidateToken(tokenString string) (*Claims, error)

type NotificationService

type NotificationService struct {
	// contains filtered or unexported fields
}

func NewNotificationService

func NewNotificationService() *NotificationService

func (*NotificationService) NotifyAward

func (s *NotificationService) NotifyAward(ctx context.Context, clientID uuid.UUID, notification BidNotification) error

NotifyAward sends a notification to a specific client about an award

func (*NotificationService) NotifyNewBid

func (s *NotificationService) NotifyNewBid(ctx context.Context, clientID uuid.UUID, notification BidNotification) error

NotifyNewBid sends a notification to a specific client about a new bid

func (*NotificationService) RegisterClient

func (s *NotificationService) RegisterClient(clientID uuid.UUID, conn *websocket.Conn)

RegisterClient registers a new WebSocket client

func (*NotificationService) UnregisterClient

func (s *NotificationService) UnregisterClient(clientID uuid.UUID)

UnregisterClient removes a WebSocket client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL