rpc

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CreditOperations tracks credit operations with labels for operation type, developer license, asset DID, and amount bucket
	CreditOperations = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "credit_tracker_operations_total",
			Help: "Total number of credit operations performed by the credit tracker service",
		},
		[]string{"operation", "developer_license", "amount_bucket"},
	)

	// CreditBalance tracks the current credit balance
	CreditBalance = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "credit_tracker_balance",
			Help: "Current credit balance tracked by the credit tracker service",
		},
		[]string{"developer_license"},
	)
)

Functions

func HandleInsufficientCredits added in v0.0.5

func HandleInsufficientCredits(ctx context.Context, assetDid string, hasCredits bool, hasDCXAndIntiatedTransaction bool) error

HandleInsufficientCredits handles the case where the user has insufficient credits

Types

type ContractProcessor added in v0.0.5

type ContractProcessor interface {
	CreateGrant(ctx context.Context, licenseID string, assetDID string, amount uint64) (*types.Transaction, error)
}

type CreditTrackerServer added in v0.0.5

type CreditTrackerServer struct {
	grpc.UnimplementedCreditTrackerServer
	// contains filtered or unexported fields
}

CreditTrackerServer represents the gRPC server

func NewServer

func NewServer(repo Repository, contractProcessor ContractProcessor) *CreditTrackerServer

NewServer creates a new instance of the gRPC server

func (*CreditTrackerServer) DeductCredits added in v0.0.5

DeductCredits implements the gRPC service method

func (*CreditTrackerServer) RefundCredits added in v0.0.5

RefundCredits implements the gRPC service method

type Repository added in v0.0.5

type Repository interface {
	DeductCredits(ctx context.Context, licenseID string, assetDID string, amount uint64, appName string, referenceID string) (*models.CreditOperation, error)
	RefundCredits(ctx context.Context, appName string, referenceID string) (*models.CreditOperation, error)
	GetBalance(ctx context.Context, licenseID, assetDID string) (int64, error)
}

Jump to

Keyboard shortcuts

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