Skip to main content

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


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 hashes)

Uploaded Source

Built Distribution

micro_client-1.0.1-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page