https://github.com/jackkweyunga/unique-codes-generator
grpc service for generating universally unique ids / codes
https://github.com/jackkweyunga/unique-codes-generator
Last synced: over 1 year ago
JSON representation
grpc service for generating universally unique ids / codes
- Host: GitHub
- URL: https://github.com/jackkweyunga/unique-codes-generator
- Owner: jackkweyunga
- Created: 2024-05-09T10:12:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-11T17:25:32.000Z (about 2 years ago)
- Last Synced: 2025-03-24T14:08:27.795Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GRPC SERVER FOR UNIQUE CODE(S) GENERATION
## Usage using ssl
- Python client
```shell
pip install ucg-client
```
- Add the following to your `example.py`
```python
import grpc
from ucg_client import generator_pb2, generator_pb2_grpc
# replace address with a domain address with https
# e.g ucg.example.com
# do not use path like example.com/ucg
channel = grpc.secure_channel('ADDRESS', grpc.ssl_channel_credentials())
stub = generator_pb2_grpc.GeneratorStub(channel)
# generate code
code = stub.GenerateUniqueCode(
generator_pb2.GenerateUniqueCodeRequest()
)
print(code)
# generates codes
codes = stub.GenerateUniqueCodes(
generator_pb2.GenerateUniqueCodesRequest(
count=100
)
)
print(codes)
```
## Development
server at: server/server.go
Run server:
```shell
cd scripts && go run server.go
```
python client at: clients/python/src/ucg_client
- Install the python client.
Build wheel
```shell
cd clients/python && sh build.sh
```
Install wheel
```shell
pip install ""
```
```python
import grpc
from ucg_client import generator_pb2, generator_pb2_grpc
channel = grpc.insecure_channel('localhost:5000')
stub = generator_pb2_grpc.GeneratorStub(channel)
# generate code
code = stub.GenerateUniqueCode(
generator_pb2.GenerateUniqueCodeRequest()
)
print(code)
# generates codes
codes = stub.GenerateUniqueCodes(
generator_pb2.GenerateUniqueCodesRequest(
count=100
)
)
print(codes)
```