Python 3 resolver for go-micro grpc services.
Project description
Python 3 resolver for go-micro grpc services.
Installation
pip install micro-client
Compiling
Make sure you have the needed protobuf and plugins.
Notes: * Make sure you have the python package grpcio-tools installed!
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
from micro_client.registry import EtcdRegistry, EtcdClient
from micro_client.common import Services
etcd_client = EtcdClient(host='localhost', port=2379)
prefix = "/micro/registry/"
s = Services(EtcdRegistry(etcd_client, prefix))
Consul
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!
# Import the stub and grpc structures for use
from some_pb2_grpc import SomeStub
from some_pb2 import Input, Structures
# Get the stub
stub = s.insecure('base_user_cf', SomeStub)
# Call it
result = stub.SomeCall(Input(Data=1), Structures(Some="data", ID=1))
# 如果 连接无法使用, reset stub
stub = s.insecure('base_user_cf', SomeStub)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
micro-client-1.0.1.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file micro-client-1.0.1.tar.gz.
File metadata
- Download URL: micro-client-1.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2fb0900217da57957953be7280d935e4134dfbe1a6cce79d6ac0924d92f4089
|
|
| MD5 |
9d7c9e6aa7f31f7edf2a0bbe59d28be2
|
|
| BLAKE2b-256 |
3239e3338b2bdc8f9cd52212fd717a5d25d964eb21c9727b1e44d385f0d0848f
|
File details
Details for the file micro_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: micro_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ebdfe519aaf3e2ecd45f858b4dd236e7cd4e82de079538d820ff359ded725b4
|
|
| MD5 |
2025c1fc91207c55cb2ffcb4fa7ecbcc
|
|
| BLAKE2b-256 |
8adba235977dc8bc1ab8ebed003fbe800a020d4d5d136814a81876aa3a39872b
|