Skip to main content

No project description provided

Project description

UniContract

UniContract is a tool designed to simplify multi-language integration by providing a shared interface contract. It generates platform-specific code from a single interface definition, ensuring consistency, flexibility, and scalability across different systems.

Features

  • Cross-Language Support: Easily integrate systems written in different programming languages.
  • Unified Interface: Generate consistent code from a single interface definition.
  • Scalability: Ideal for large-scale, multi-language projects.
  • Redundancy-Free: Eliminates the need to define interfaces multiple times.
  • Ease of Maintenance: Promotes simpler, more maintainable code.

Purpose and Usage

The primary use case for UniContract is to establish a unified interface design, independent of the programming language used for implementation. This project does not solve cross-platform communication between programming languages but instead focuses on ensuring consistency in a multi-language environment.

For example, in a microservice architecture where multiple languages are employed, UniContract helps ensure that solutions remain uniform. Developers switching from one programming language to another within the same project will encounter familiar functionality and design patterns, making transitions seamless. Learning the behavior of a specific interface in one language enables developers to predict its behavior in another.

By providing a single source of truth for interface definitions, UniContract reduces development overhead and potential discrepancies that arise from manually maintaining multiple definitions across different platforms. This consistency fosters better collaboration among developers and improves the overall reliability of multi-language systems.

Practical Example

One of the best examples of this approach is an interface for database operations. Imagine a unified interface for storing, modifying, and retrieving entities, which works the same regardless of the underlying language. For instance, whether working in Java, Python, or C#, the interface behaves predictably, and the expected functionality remains consistent. This enables developers to work efficiently across different services and programming languages without steep learning curves.

For example, an interface like DataStore could define methods for basic CRUD operations:

  • Create: Adding a new entity to the database.
  • Read: Retrieving data based on specific conditions.
  • Update: Modifying existing data.
  • Delete: Removing data.

With UniContract, the same DataStore interface can be generated in multiple programming languages, ensuring that developers always interact with familiar constructs.

Related Projects

UniContract is part of the MicronIQ project, a broader initiative to create consistent, language-agnostic patterns for microservices. One key implementation of UniContract can be found in the PolyPersist project, which leverages this tool to provide a unified interface for database operations. Check out the PolyPersist project here:

PolyPersist on GitHub

Installation and Usage

# Clone the repository
git clone https://github.com/your-username/unicontract.git

# Navigate into the directory
cd unicontract

# Follow setup instructions based on your environment
# Example: Run installation script or configure dependencies

# Example Interface Definition (user-service.contract)
#
# interface UserService {
#   method getUser(userId: string) -> User
# }
#
# interface User {
#   property id: string
#   property name: string
# }

# To generate code for multiple languages from the interface definition:
unicontract --input user-service.contract --emitter ./emmitters/java.py -emitter ./emmitters/python.py -emitter ./emmitters/dotnet.py

# This will generate the necessary code files for the UserService interface
# in Java, Python, and C#.

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

unicontract-0.1.10.tar.gz (64.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unicontract-0.1.10-py3-none-any.whl (71.9 kB view details)

Uploaded Python 3

File details

Details for the file unicontract-0.1.10.tar.gz.

File metadata

  • Download URL: unicontract-0.1.10.tar.gz
  • Upload date:
  • Size: 64.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for unicontract-0.1.10.tar.gz
Algorithm Hash digest
SHA256 dbdd1c597bc640830b8978fc82a1958e4652e3f1774fd71b037e35952e71ce9a
MD5 cfdf985ba1c0e8efe77e190d095a7dc5
BLAKE2b-256 3e1e11ebbe0b4b648393af26ebb2d1b3a6e57808e317c3a7bd2ce1010a04b96d

See more details on using hashes here.

File details

Details for the file unicontract-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: unicontract-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 71.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for unicontract-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f7afb9be27bd13610933933b26b2aa205fcaa191dda68bb8f3a24ec46f348c24
MD5 d5a25cf1cab75a65813438d889549e6e
BLAKE2b-256 3f5b751f50efb83798bd2c73ea49ac0c463c5b94a1f92bb41a020ca4edbb4a02

See more details on using hashes here.

Supported by

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