This section introduces the following content:
Pulsar Functions are a serverless computing framework that runs on top of Pulsar and processes messages in the following way:
The following figure illustrates the computing process of a function.
A function receives messages from one or more input topics. Each time messages are received, the function completes the following steps:
You can write functions in Java, Python, and Go. For example, you can use Pulsar Functions to set up the following processing chain:
raw-sentences
topic and “sanitizes” incoming strings (removing extraneous white space and converting all characters to lowercase) and then publishes the results to a sanitized-sentences
topic.sanitized-sentences
topic, counts the number of times each word appears within a specified time window, and publishes the results to a results
topic.results
topic and writes the results to a MySQL table.See Develop Pulsar Functions for more details.
Pulsar Functions provide the capabilities to perform simple computations on the messages before they are routed to consumers.
Pulsar Functions can be characterized as Lambda-style functions that are specifically designed and integrated with Pulsar as the underlying message bus. The framework of Pulsar Functions provides a simple computing framework on your Pulsar cluster and takes care of the underlying details of sending/receiving messages. You only need to focus on the business logic and run it as Pulsar Functions to maximize the value of your data and enjoy the benefits of:
Here are two real-world use cases to help you understand the capabilities of Pulsar Functions and what they can be used for.
This figure illustrates the process of implementing the classic word count example using Pulsar Functions. It calculates a sum of the occurrences of every individual word published to a given topic.
For example, a function takes items (strings) as input and publishes them to either a fruits
or vegetables
topic, depending on the item. If an item is neither fruit nor vegetable, a warning is logged to a log topic.
This figure demonstrates the process of implementing a content-based routing using Pulsar Functions.
Admins/operators
Developers
More reference