Creating a base interface

As we mentioned previously, an interface is a contract, plain and simple. The interface for our base microservice is going to be relatively simple. The following is what our interface looks like:

public interface IBaseMicroService
{
void Start(HostControl hc);
void Stop();
void Pause();
void Continue();
void Shutdown();
void Resume();
void TryRequest(Action action, int maxFailures, int startTimeoutMS = 100, int resetTimeout = 10000, Action<Exception> OnError = null);
Task TryRequestAsync([NotNull] Func<Task> action, int maxFailures, int startTimeoutMS = 100, int resetTimeout = 10000, [CanBeNull] Action<Exception> OnError = null);void PublishMessage(object message, string connStr = "host=localhost", string topic = "");
Task PublishMessageAsync(object message, string connStr = "host=localhost", string topic = "");
}

You will notice that our interface, aside from the TryRequest functions, really only controls the motion of our microservice. This means that every microservice that inherits from this interface must implement these methods. So, let's go ahead and start defining our base microservice and decide what we need to implement. Remember that you can adjust things to your preference as you get up and running.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset