Memphis.dev is more than a broker. It's a new streaming stack.
Memphis.dev is a highly scalable event streaming and processing engine.
Before Memphis came along, handling ingestion and processing of events on a large scale took months to adopt and was a capability reserved for the top 20% of mega-companies. Now, Memphis opens the door for the other 80% to unleash their event and data streaming superpowers quickly, easily, and with great cost-effectiveness.
Memphis Functions Is Part of Memphis.dev Platform For Developing Highly-Customizable Event-driven Features and Pipelines By Creating or Employing Serverless Functions.
This repository is to provide ready-to-use templates for writing Memphis Functions.
Supported languages:
| |
- Create a Memphis.dev Account
- Create a new station
- Attach a new function
- Produce some messages
A function comprises code files based on the templates located in this repository and a memphis.yaml
file contained within a unified directory.
The directory ought to be included in a Git repository that's linked with Memphis.
Here is a brief hierarchy diagram of how a compatible function file tree should be constructed:
- Clone or create a new repository (At the moment, support is exclusively available for GitHub.)
- Within this repository, establish a fresh directory and initialize it to your chosen programming language
mkdir my-function && cd my-function && npm init -y
- Copy one of the Memphis Functions templates. For this guide, we chose Node.js
- Required. Write your logic inside the
eventHandler
block.
Incoming events will be accumulated and dispatched to a function collectively in a batch, therefore the wrapper
exports.handler = async (event) => {
return await createFunction(event, eventHandler);
};
/**
* https://github.com/memphisdev/memphis.js/tree/functions_wrapper#creating-a-memphis-function
* @param {Uint8Array} payload
* @param {Object} headers
* @param {Object} inputs
* @returns {Object}
*/
function eventHandler(payload, headers, inputs) {
// Handle event here
// A short example of converting the payload to a json object and returning it as an Uint8Array
const decodedPayload = payload.toString('utf-8');
const asJson = JSON.parse(decodedPayload);
return {
processedMessage: Buffer.from(JSON.stringify(asJson), 'utf-8'),
processedHeaders: headers
};
}
Messages will return to the Memphis Station in a batch as well.
5. Required. Add or modify the memphis.yaml
file based on the following template:
function_name: #Required. Must be equal to the directory name
runtime: #Required. [go | nodejs | nodejs16.x | nodejs18.x | python3.8 | python3.9 | python3.10 | python3.11]
dependencies: #The file name contains the list of dependencies the function making use of - default to [requirements.txt(python) / go.mod(go) / package.json (nodes)]
handler: #Required for node.js/Python only. The name of the function's entry point - <file name>.<function name> - for example, if your function is called 'handler' and written inside 'main.py', the handler should be main.handler
tags: #List of tags
- tag: json
- tag: dev
inputs: #list of input fields that will be injected into your function per attachment
- name: timestamp
description: #Description
- Optional. Add a README file to describe your function so others will know what to do :)
- Connect the designated repository with your Memphis account
my-function
should be available through the Functions main page or a station
- Fork https://github.com/memphisdev/memphis-dev-functions
- Add your function's directory, including
memphis.yaml
file - Create a PR
- The addition of the new function will take place following a thorough review and subsequent approval
- Get your swag pack! 😍