rate

module
v0.0.0-...-48058a4 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MPL-2.0

README

Protocol Documentation

Table of Contents

Top

Rate Service

Rate service adds the markup on the base rates and provides the final applicable rates for the user.

If the user doesn't have any custom rates for him then the default markup is applied otherwise custom markup is considered

RPC Functions

Method Name Request Type Response Type Description
GetMarkup GetMarkupRequest GetMarkupResponse
UpdateMarkup UpdateMarkupRequest UpdateMarkupResponse
DeleteMarkup DeleteMarkupRequest DeleteMarkupResponse
GetMarkupHistory GetMarkupHistoryRequest GetMarkupHistoryResponse
GetDefaultMarkup GetDefaultMarkupRequest GetDefaultMarkupResponse
UpdateDefaultMarkup UpdateDefaultMarkupRequest UpdateDefaultMarkupResponse
GetDefaultMarkupHistory GetDefaultMarkupHistoryRequest GetDefaultMarkupHistoryResponse
GetRates GetRatesRequest GetRatesResponse
GetRate GetRateRequest GetRateResponse

Directory structure

  • cmd: Contains the server and system/sub-system version. Purpose of this file is to initialize the DB and start server. We use make server command to run this file.
  • mocks: This directory contains the auto generated file which get generated based on *.proto. It contains functions which we can use to write test cases.
  • pb: This directory contains the *.proto file. In proto file we define service with all the rpc's and messages.
  • pkg/db: DB directory under pkg contains 2 files. model.go file contains the db model structure/s. *_repo.go is reponsible of communicating with db using gorm.
  • pkg/server This directory contains the file in which all the RPC functions logic is implemented. Those functions call pkg\*_repo.go functions to perform db operations.

How to use?

Before using the repo make sure below tools are installed:

  • Go 1.18
  • PostgreSQL
  • gRPC client Then navigate into base-rate directory and run below command:

To Test

For unit tests run below commands:

make test

This command will run unit tests under all rate.proto directories.

To Generate PB file

make gen

This command will generate protobuf files from rate.proto.

To Run Server & Test RPC

make server

This command will run the server on port 9090. It'll also create the database and table under it.

Server is running, Now we can use any gRPC client to interact with RPC handlers. We're using Evans. Run below command in new terminal tab:

evans --path /path/to --path . --proto pb/*.proto --host localhost --port 9090

Next run:

show rpc

This command will show all the available RPC calls under base-rate sub-system. To call any RPC function run call FUNCATION_NAME.

rate.proto

DeleteMarkupRequest
Field Type Label Description
ownerId string

DeleteMarkupResponse

GetDefaultMarkupHistoryRequest

GetDefaultMarkupHistoryResponse
Field Type Label Description
markupRates MarkupRates repeated

GetDefaultMarkupRequest

GetDefaultMarkupResponse
Field Type Label Description
Markup double

GetMarkupHistoryRequest
Field Type Label Description
ownerId string

GetMarkupHistoryResponse
Field Type Label Description
ownerId string
markupRates MarkupRates repeated

GetMarkupRequest
Field Type Label Description
ownerId string

GetMarkupResponse
Field Type Label Description
ownerId string
Markup double

GetRateRequest
Field Type Label Description
ownerId string
country string
provider string
to uint64
from uint64
simType string
effectiveAt string

GetRateResponse
Field Type Label Description
rates ukama.dataplan.baserate.v1.Rate repeated

GetRatesRequest
Field Type Label Description
country string
provider string
to uint64
from uint64
simType string
effectiveAt string

GetRatesResponse
Field Type Label Description
rates ukama.dataplan.baserate.v1.Rate repeated

MarkupRates
Field Type Label Description
createdAt string
deletedAt string
Markup double

UpdateDefaultMarkupRequest
Field Type Label Description
Markup double

UpdateDefaultMarkupResponse

UpdateMarkupRequest
Field Type Label Description
ownerId string
Markup double

UpdateMarkupResponse

Scalar Value Types

.proto Type Notes C++ Type Java Type Python Type
double double double float
float float float float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long
uint32 Uses variable-length encoding. uint32 int int/long
uint64 Uses variable-length encoding. uint64 long int/long
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long
sfixed32 Always four bytes. int32 int int
sfixed64 Always eight bytes. int64 long int/long
bool bool boolean boolean
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode
bytes May contain any arbitrary sequence of bytes. string ByteString str

Directories

Path Synopsis
cmd
pb
gen
pkg
db

Jump to

Keyboard shortcuts

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