https://github.com/ashcrow/micro-client
go-micro grpc resolver/client in python
https://github.com/ashcrow/micro-client
client micro micro-library python python3
Last synced: 10 months ago
JSON representation
go-micro grpc resolver/client in python
- Host: GitHub
- URL: https://github.com/ashcrow/micro-client
- Owner: ashcrow
- License: mit
- Created: 2017-12-30T02:23:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-10T16:43:24.000Z (almost 8 years ago)
- Last Synced: 2025-04-07T15:55:16.437Z (about 1 year ago)
- Topics: client, micro, micro-library, python, python3
- Language: Python
- Size: 3.91 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mico-client
Python 3 resolver for [go-micro](https://github.com/micro/go-micro) grpc
services.
[](https://travis-ci.org/ashcrow/micro-client)
## Examples
### Compiling
Make sure you have [the needed protobuf and plugins](https://github.com/micro/go-micro#install-protobuf).
**Notes**:
* You will need to set or replace the variables!
* Make sure you have the python package *grpcio-tools* installed!
```shell
PATH=$PATH:$GOBIN_PATH protoc -I=$SOURCE_OF_MICRO_PROJECT --proto_path=$GOPATH/src:. --python_out=plugins=micro,grpc:. $PATH_TO_PROTO_FILE
python -m grpc_tools.protoc -I=$SOURCE_OF_MICRO_PROJECT --python_out=. --grpc_python_out=. $PATH_TO_PROTO_FILE
```
### Etcd
```python
from micro_client.registry.etcdregistry import etcd, Registry
from micro_client.common import Services
s = Services(Registry(etcd.Client(port=2379), '/micro-registry'))
```
### Consul
```python
import requests
from micro_client.registry.consulregistry import Registry
from micro_client.common import Services
s = Services('http://127.0.0.1:8500/v1', session=requests.Session()))
```
### Use it!
```python
service = s.resolve('some')
print(service.connection_info)
# Import the stub and grpc structures for use
import grpc
from some_pb2_grpc import SomeStub
from some_pb2 import Input, Structures
# Get the stub
stub = services.insecure('some', SomeStub)
# Call it
result = stub.SomeCall(Input(Data=1), Structures(Some="data", ID=1))
```