Skip to content

BlobProvider

Juraj Bielik edited this page Oct 14, 2019 · 2 revisions

Kentico Kontent Docs - Blob Provider

Overview

Blob Provider is a microservice responsible for serving up-to-date HTML with API reference to the Kentico Kontent Docs website. The API reference is modeled in the Kentico Kontent. The Blob Provider service is written in C# as a Durable function with EventGridEvent triggers and an HTTP trigger.

Specification

Triggers

HTTP
ProviderStarter

ProviderStarter is a starter function with an HTTP trigger, which is used by the Kentico Kontent Docs website to retrieve HTML with API reference specified by its codename.

EventGridEvent
BlobCreatedStarter

BlobCreatedStarter is another starter function which is triggered when a blob is created by the OpenAPI Processor. The service is also triggered by the API Reference Preprocessor when there was a change in the API reference made in the Kentico Kontent.

ReferenceUpdateStarter

ReferenceUpdateStarter is the last of the 3 starter functions. Its responsibility is to start the Orchestrator when the API reference was updated in the Kentico Kontent and then notify the website that there will be a new API reference page. The function is triggered by the API Reference Preprocessor service using EventGrid events.

How it works

The Blob Provider service deals with 3 different scenarios:

  1. The Kentico Kontent Docs website asks for a live API reference page
  2. The Kentico Kontent Docs website asks for a preview API reference page
  3. The API reference is changed in the Kentico Kontent

In the first case, the web requests with an API reference codename to the HTTP trigger starter endpoint and awaits a response with the HTML containing the API reference. The starter starts an Orchestrator by its instance id, and the Orchestrator invokes activities that do the hard work. Whenever there is a request to one of the API references and the website doesn't have it in its cache, a new instance of the ProviderStarter is created. Every instance of the starter function has access to Orchestrator instances (which can store data in themselves), which brings an advantage in terms of optimizations. The ProviderStarter instances can either:

  1. Start a new Orchestrator instance (with an instance id of the API reference which was requested), which will cause regeneration of the API reference by other services. The Orchestrator first calls an activity that triggers the API Reference Preprocessor service and then waits for an external event. After a new blob is created by the OpenAPI Processor, the BlobCreatedStarter function is invoked and raises a new event with the blob URL and an instance id of the Orchestrator, which is equivalent to the API Reference root item's codename. The Orchestrator receives the event with the blob URL and invokes an activity that retrieves the blob from the Blob storage. The result is stored in the Orchestrator instance which can be retrieved in the Starter function.
  2. Wait for an Orchestrator instance to finish - the starter function can ask about the running state of an Orchestrator instance. When the process is finished, the starter returns the result from the Orchestrator instance.
  3. Return immediately the result from the Orchestrator instance (if available), i.e. when the Orchestrator instance's running status is completed.

In the second case, when the website asks for a preview API reference page, the starter never checks for the history of Orchestrator instances but always starts a new Orchestrator instance, waits for the result and then returns it to the website.

The third case is initiated by a content change in the API reference in the Kentico Kontent. A webhook is sent to the Dispatcher, which triggers the API Reference Preprocessor and that triggers the ReferenceUpdateStarter. This starter then starts the Orchestrator, which will be waiting for the external event. The second responsibility of the ReferenceUpdateStarter is to notify the Kentico Kontent Docs website that the API Reference has been updated and that the web is supposed to fetch the new version through ProviderStarter function, where the starter will get the new API reference from the Orchestrator instance.