sharedkernel

package
v0.0.0-...-e157847 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServer          = status.Error(codes.Internal, "Server error")
	ErrMissingMetadata = status.Error(codes.InvalidArgument, "missing metadata")
	ErrInvalidToken    = status.Error(codes.Unauthenticated, "invalid token")
	ErrUsersNotFound   = status.Error(codes.InvalidArgument, "users not found")
)

Functions

func CreateAccessToken

func CreateAccessToken(ctx context.Context, data UserData) (string, error)

func CreateRefreshToken

func CreateRefreshToken(ctx context.Context, id uuid.UUID) (string, error)

func GetToken

func GetToken(ctx context.Context) (string, error)

func GetUserIDFromContext

func GetUserIDFromContext(ctx context.Context) (uuid.UUID, error)

func RefreshAccessToken

func RefreshAccessToken(ctx context.Context, tokenString string, data UserData) (string, error)

func TokenInterceptor

func TokenInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	Username string
	Email    string
	jwt.StandardClaims
}

func ParseToken

func ParseToken(ctx context.Context, tokenString string) (AccessTokenClaims, error)

type Broker

type Broker[T any] struct {
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker[T any]() *Broker[T]

func (*Broker[T]) Publish

func (b *Broker[T]) Publish(msg T)

func (*Broker[T]) Start

func (b *Broker[T]) Start()

func (*Broker[T]) Stop

func (b *Broker[T]) Stop()

func (*Broker[T]) Subscribe

func (b *Broker[T]) Subscribe() chan T

func (*Broker[T]) Unsubscribe

func (b *Broker[T]) Unsubscribe(msgCh chan T)

type Instruction

type Instruction struct {
	State    string `json:"state"`
	TimeCode int    `json:"timecode"`
}

type Message

type Message struct {
	Instruction *Instruction
	Sender      string
}

type RefreshTokenClaims

type RefreshTokenClaims struct {
	jwt.StandardClaims
}

type UserData

type UserData struct {
	Username string
	Email    string
	ID       uuid.UUID
}

Jump to

Keyboard shortcuts

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