api

package
v0.0.0-...-dec55d9 Latest Latest
Warning

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

Go to latest
Published: May 12, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveQuotaCheckTokenMiddleware

func ActiveQuotaCheckTokenMiddleware(
	jwtSecret ed25519.PublicKey,
) grpc.UnaryServerInterceptor

func AdminAuthMiddleware

func AdminAuthMiddleware(adminIds []int64, jwtSecret ed25519.PublicKey) grpcauth.AuthFunc

func AdminAuthMiddlewareSelector

func AdminAuthMiddlewareSelector(ctx context.Context, callMeta interceptors.CallMeta) bool

func AuthMiddleware

func AuthMiddleware(
	jwtSecret ed25519.PublicKey,
) grpc.UnaryServerInterceptor

func AuthMiddlewareSelector

func AuthMiddlewareSelector(ctx context.Context, callMeta interceptors.CallMeta) bool

func FreeQuotaRedisRateLimiterSelector

func FreeQuotaRedisRateLimiterSelector(ctx context.Context, callMeta interceptors.CallMeta) bool

func IsReadOnlyMethod

func IsReadOnlyMethod(methodName string) bool

func NewGrpcServer

func NewGrpcServer(server *Server) *grpc.Server

func ParseHeaderJwt

func ParseHeaderJwt(
	ctx context.Context,
	claims jwt.Claims,
	jwtSecret ed25519.PublicKey,
	headerField string,
	withValdidation bool,
) (interface{}, error)

func QuotaTokenValidityMiddleware

func QuotaTokenValidityMiddleware(
	jwtSecret ed25519.PublicKey,
) grpc.UnaryServerInterceptor

func ServiceRegisterAuthMiddlewareSelector

func ServiceRegisterAuthMiddlewareSelector(ctx context.Context, callMeta interceptors.CallMeta) bool

func SoldQuotaRedisLimiterSelector

func SoldQuotaRedisLimiterSelector(ctx context.Context, callMeta interceptors.CallMeta) bool

func TokenFromMD

func TokenFromMD(ctx context.Context, headerField string) (string, error)

Adapted from grpcauth.AuthFromMD but allows other than authorization header

Types

type AuthClaims

type AuthClaims struct {
	AccountId int64
}

func ParseAuthToken

func ParseAuthToken(ctx context.Context, jwtSecret ed25519.PublicKey, withValidation bool) (*AuthClaims, error)

type DbState

type DbState struct {
	AdminAccountId     int64
	FreeQuotaServiceId int64
	SoldQuotaServiceId int64
}

type FreeQuotaRedisRateLimiter

type FreeQuotaRedisRateLimiter struct {
	Rdb                *redis.Client
	RefreshPeriod      time.Duration
	FreeQuotaServiceId int64
	// contains filtered or unexported fields
}

func (*FreeQuotaRedisRateLimiter) Limit

type QuotaRedisLimiter

type QuotaRedisLimiter struct {
	Rdb *redis.Client
	// contains filtered or unexported fields
}

func (*QuotaRedisLimiter) Limit

func (l *QuotaRedisLimiter) Limit(ctx context.Context) error

type QuotaTokenClaims

type QuotaTokenClaims struct {
	ServiceID     int64 `json:"service_id"`
	QuotaQuantity int64 `json:"quota_quantity"`
	*jwt.RegisteredClaims
}

func ParseQuotaToken

func ParseQuotaToken(ctx context.Context, jwtSecret ed25519.PublicKey) (*QuotaTokenClaims, error)

type RemoveServiceRequest

type RemoveServiceRequest struct {
	ServiceId int64 `json:"service_id" binding:"required"`
}

type RequestWithAccount

type RequestWithAccount interface {
	GetAccountId() int64
}

type Resource

type Resource interface {
	GetName() string
}

type ResourceParent

type ResourceParent interface {
	GetParent() string
}

type Server

type Server struct {
	pb.ExchangeServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config config.Config, store store.Store) (*Server, error)

func (*Server) ActivateQuotaToken

func (s *Server) ActivateQuotaToken(
	ctx context.Context, req *pb.ActivateQuotaTokenRequest,
) (*pb.ActivateQuotaTokenResponse, error)

func (*Server) BatchMarkWithdraws

func (s *Server) BatchMarkWithdraws(
	ctx context.Context,
	req *pb.BatchMarkWithdrawsRequest,
) (*pb.BatchMarkWithdrawsResponse, error)

func (*Server) BatchProcessWithdraws

func (s *Server) BatchProcessWithdraws(
	ctx context.Context,
	req *pb.BatchProcessWithdrawsRequest,
) (*pb.BatchProcessWithdrawsResponse, error)

func (*Server) ClaimFreeToken

func (s *Server) ClaimFreeToken(
	ctx context.Context, req *pb.ClaimTokenRequest,
) (*pb.ClaimTokenResponse, error)

func (*Server) ClaimToken

func (s *Server) ClaimToken(
	ctx context.Context, req *pb.ClaimTokenRequest,
) (*pb.ClaimTokenResponse, error)

func (*Server) CreateSellOrder

func (s *Server) CreateSellOrder(
	ctx context.Context, req *pb.CreateSellOrderRequest,
) (*pb.CreateSellOrderResponse, error)

func (*Server) CreateService

func (s *Server) CreateService(
	ctx context.Context,
	req *pb.CreateServiceRequest,
) (*pb.CreateServiceResponse, error)

func (*Server) CreateServicesFromDb

func (s *Server) CreateServicesFromDb(
	ctx context.Context,
) error

func (*Server) CreateWithdraw

func (s *Server) CreateWithdraw(ctx context.Context, req *pb.CreateWithdrawRequest) (*pb.Withdrawal, error)

func (*Server) DeleteSellOrder

func (s *Server) DeleteSellOrder(
	ctx context.Context,
	req *pb.DeleteSellOrderRequest,
) (*emptypb.Empty, error)

func (*Server) DeleteService

func (s *Server) DeleteService(
	ctx context.Context, req *pb.DeleteServiceRequest,
) (*emptypb.Empty, error)

func (*Server) Deposit

func (s *Server) Deposit(ctx context.Context, req *pb.DepositRequest) (*pb.DepositResponse, error)

func (*Server) GetChallenge

func (s *Server) GetChallenge(ctx context.Context, req *pb.GetChallengeRequest) (*pb.GetChallengeResponse, error)

func (*Server) GetConfig

func (s *Server) GetConfig() *config.Config

func (*Server) GetRedisClient

func (s *Server) GetRedisClient() *redis.Client

func (*Server) InitDb

func (s *Server) InitDb(
	ctx context.Context,
) DbState

func (*Server) ListFulfilledOrders

func (s *Server) ListFulfilledOrders(
	ctx context.Context, req *pb.ListFulfilledOrdersRequest,
) (*pb.ListFulfilledOrdersResponse, error)

func (*Server) ListPaymentMethods

func (s *Server) ListPaymentMethods(
	ctx context.Context,
	req *pb.ListPaymentMethodsRequest,
) (*pb.ListPaymentMethodsResponse, error)

func (*Server) ListServices

func (s *Server) ListServices(
	ctx context.Context,
	req *pb.ListServicesRequest,
) (*pb.ListServicesResponse, error)

func (*Server) Login

func (s *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error)

func (*Server) MatchOrder

func (s *Server) MatchOrder(
	ctx context.Context, req *pb.MatchOrderRequest,
) (*pb.MatchOrderResponse, error)

func (*Server) Ping

func (s *Server) Ping(ctx context.Context, _ *emptypb.Empty) (*pb.PingResponse, error)

func (*Server) PruneAccounts

func (s *Server) PruneAccounts(
	ctx context.Context,
	req *pb.PruneAccountsRequest,
) (*pb.PruneAccountsResponse, error)

Jump to

Keyboard shortcuts

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