Skip to main content

Library for communication with microservices developed by phonexia using grpc application interface.

Project description

Phonexia microservice communication via grpc library

This library contains defined interfaces for all microservices developed by Phonexia.

To use this library you will first need a running instance of any Phonexia microservice. If you don't yet have any running instance, don't hesitate to contact our sales department.

On this page, you may find a gRPC API reference for all microservices.

Example

Examples require microservice running on local machine at port 8080.

Health check

You can invoke health check method of any microservice like this:

import grpc

from phonexia.grpc.common.health_check_pb2 import HealthCheckRequest
from phonexia.grpc.common.health_check_pb2_grpc import HealthStub


def health_check(stub: HealthStub):
    """Create request and call the service.
    Invoke Info method of the health stub.
    Args:
        stub (LicensingStub): Created stub for communication with service.
    """
    request = HealthCheckRequest()
    response = stub.Check(request)
    print(response)


def main():
    """Create a gRPC channel and connect to the service."""
    with grpc.insecure_channel(target="localhost:8080") as channel:
        """Create channel to the service.
        The target parameter is the service address and port.
        insecure channel is used for connection without TLS.
        To use SSl/TLS see the grpc_secure_channel function.
        """
        stub = HealthStub(channel)
        health_check(stub)


if __name__ == "__main__":
    main()

If the microservice is running, it should return: status: SERVING.

Check license

Each microservice has licensed model which is required to run the service. You can fetch information about licensed models like this:

import grpc

from phonexia.grpc.common.licensing_pb2 import LicensingInfoRequest
from phonexia.grpc.common.licensing_pb2_grpc import LicensingStub


def licensing_check(stub: LicensingStub):
    """Create request and call the service.
    Invoke Info method of the Licensing stub.
    Args:
        stub (LicensingStub): Created stub for communication with service.
    """
    request = LicensingInfoRequest()
    response = stub.Info(request)
    print(
        f"The license for technology '{response.technology_name}' with model"
        f" '{response.model_info.name}:{response.model_info.version}'"
        f" {'is' if response.is_valid else 'was'} valid until {response.valid_until}."
    )


def main():
    """Create a gRPC channel and connect to the service."""
    with grpc.insecure_channel(target="localhost:8080") as channel:
        """Create channel to the service.
        The target parameter is the service address and port.
        insecure channel is used for connection without TLS.
        To use SSl/TLS see the grpc_secure_channel function.
        """
        stub = LicensingStub(channel=channel)
        licensing_check(stub)


if __name__ == "__main__":
    main()

Returned message should contain information about technology name, model name with version and time validity of license.

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

phonexia_grpc-2.3.1.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

phonexia_grpc-2.3.1-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

Details for the file phonexia_grpc-2.3.1.tar.gz.

File metadata

  • Download URL: phonexia_grpc-2.3.1.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/5.14.0-362.8.1.el9_3.x86_64

File hashes

Hashes for phonexia_grpc-2.3.1.tar.gz
Algorithm Hash digest
SHA256 ea4e3b0081f18e002a97286412df20b054657adf32c434b4353e72ed347211cb
MD5 c4c40da1cebcfa61576f0e0363e2891c
BLAKE2b-256 7cc6a26b19514dd5274ae5d2aa6053b1fbceff2092a7e0d685a88b3f3756420f

See more details on using hashes here.

File details

Details for the file phonexia_grpc-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: phonexia_grpc-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 46.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/5.14.0-362.8.1.el9_3.x86_64

File hashes

Hashes for phonexia_grpc-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56f97cde0d11b823bd07f26fdc7d5ca7f7dba31809b364b2202ef6e3c8630a3f
MD5 735f3decf7c39f7102745ff46f315f08
BLAKE2b-256 c5f2b48c5c18232f18fdfe37adae61bee31f8afe8b677b33bdb6cd48e0d711a8

See more details on using hashes here.

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