lundi 10 mai 2021

Implementing Service Provider Interface pattern in python

I am from Java background and I want to know how to implement something similar to SPI pattern in python : How to implement the API/SPI Pattern in Java?

Basically, we building a Platform and we want to distribute the SDK/API packages to the "platform users" who will build Data Pipelines on top of the platform.

We only want to share the interfaces and actual implementation is resolved during the runtime by the Platform.

For example, following SDK class/interface is shared to the Platform user and during runtime when their code invokes IEventLog.send_event() method, Platform will send the event to the kafka using a Kafka Producer.

class IEventLog(object):
    def __init__(self):
        pass
    def send_event(self,qn,corrId):
        raise Exception("Error Runtime feature")

Aucun commentaire:

Enregistrer un commentaire