kalix gradient

Developer

Documentation and guides for building high performance microservices and APIs

Get going with Kalix in 3 easy steps based on programming language of your choice

kalix tabs gradient

1Design your API and data model

Design your API

//request
message AddItemRequest {
  string cart_id = 1;
  string item_id = 2;
  int32 item_quantity = 3;
}
message CheckOutRequest {
  string cart_id = 1;
}
//service
service ShoppingCartService {
  rpc AddItem (AddItemRequest) returns (Empty);
  rpc CheckOut (CheckOutRequest) returns (Empty);
}

Describe API endpoints and API data model. Expose your API as gRPC, REST or let it connect to a message broker.

Design your data

//state
message Cart {
  string cart_id = 1;
  repeated CartItem items = 2;
}
message CartItem {
  string item_id = 1;
  int32 quantity = 2;
}
//event
message ItemAdded {
  string cart_id = 1;
  string item_id = 2;
  int32 quantity = 3;
}
//event
message CheckedOut {
  string cart_id = 1;
}

Describe your domain data and choose your preferred durable storage model (key/value, event sourcing, or CRDTs).

2Implement your business logic

public Effect<Empty> addItem(Cart currentState, AddItemRequest request) {
  if(!checkItemExists(currentState, request)){
    Cart newState = currentState.toBuilder().addItems(item).build();
    return effects()
      .updateState(newState)
      .thenReply(Empty.getDefaultInstance());
  } else {
    return effects().error("Item already added");
  }
}

Kalix Maven plugin, based on the defined API, generates required resources for focusing only on implementing the business logic code.

NO CODE required for data persistence and query. The data is automatically injected into your service on an as-needed basis, and queries are consumed through live materialized views.

3Deploy

kalix service deploy shoppingcart myrepo/shoppingcart:latest

Kalix Maven plugin builds and publishes the image to an image repository of your choice and the Kalix CLI tool is used to deploy and manage your service on Kalix.

Kalix, as a fully managed runtime environment, removes a need for any operations and maintenance of the infrastructure and takes care of security, logging, monitoring, zero-downtime upgrades, and auto-scaling.

1Design your API and data model

Design your API

//request
message AddItemRequest {
  string cart_id = 1;
  string item_id = 2;
  int32 item_quantity = 3;
}
message CheckOutRequest {
  string cart_id = 1;
}
//service
service ShoppingCartService {
  rpc AddItem (AddItemRequest) returns (Empty);
  rpc CheckOut (CheckOutRequest) returns (Empty);
}

Describe API endpoints and API data model. Expose your API as gRPC, REST or let it connect to a message broker.

Design your data

//state
message Cart {
  string cart_id = 1;
  repeated CartItem items = 2;
}
message CartItem {
  string item_id = 1;
  int32 quantity = 2;
}
//event
message ItemAdded {
  string cart_id = 1;
  string item_id = 2;
  int32 quantity = 3;
}
//event
message CheckedOut {
  string cart_id = 1;
}

Describe your domain data and choose your preferred durable storage model (key/value, event sourcing, or CRDTs).

2Implement your business logic

override def addItem(currentState: Cart, request: AddItemRequest):
ValueEntity.Effect[Empty] = {
  if(!checkItemExists(currentState, request)){
    val newState : Cart = currentState.withItems(currentState.items :+ request.item)
    effects
      .updateState(newState)
      .thenReply(_ => Empty.defaultInstance)
  } else {
    effects.error("Item already added")
  }
}

Kalix SBT plugin, based on the defined API, generates required resources for focusing only on implementing the business logic code.

NO CODE required for data persistence and query. The data is automatically injected into your service on an as-needed basis, and queries are consumed through live materialized views.

3Deploy

kalix service deploy shoppingcart myrepo/shoppingcart:latest

Kalix SBT plugin builds and publishes the image to an image repository of your choice and the Kalix CLI tool is used to deploy and manage your service on Kalix.

Kalix, as a fully managed runtime environment, removes a need for any operations and maintenance of the infrastructure and takes care of security, logging, monitoring, zero-downtime upgrades, and auto-scaling.

1Design your API and data model

Design your API

//request
message AddItemRequest {
  string cart_id = 1;
  string item_id = 2;
  int32 item_quantity = 3;
}
message CheckOutRequest {
  string cart_id = 1;
}
//service
service ShoppingCartService {
  rpc AddItem (AddItemRequest) returns (Empty);
  rpc CheckOut (CheckOutRequest) returns (Empty);
}

Describe API endpoints and API data model. Expose your API as gRPC, REST or let it connect to a message broker.

Design your data

//state
message Cart {
  string cart_id = 1;
  repeated CartItem items = 2;
}
message CartItem {
  string item_id = 1;
  int32 quantity = 2;
}
//event
message ItemAdded {
  string cart_id = 1;
  string item_id = 2;
  int32 quantity = 3;
}
//event
message CheckedOut {
  string cart_id = 1;
}

Describe your domain data and choose your preferred durable storage model (key/value, event sourcing, or CRDTs).

2Implement your business logic

JavaScript

TypeScript

function addItem(request, state, ctx) {
 if(!checkItemExists(state, request)){
   state.items.push(request.item);
   ctx.updateState(state);
   return Reply.message({});
 } else {
   return Reply.failure(`Item already added`);
 }
}
function addItem(request: AddItemRequest, state: Cart, ctx: CommandContext): Reply<Empty> {
 if(!checkItemExists(state, request)){
   state.items.push(request.item);
   ctx.updateState(state);
   return Reply.message({});
 } else {
   return Reply.failure(`Item already added`);
 }
}

Kalix NPM plugin, based on the defined API, generates required resources for focusing only on implementing the business logic code.

NO CODE required for data persistence and query. The data is automatically injected into your service on an as-needed basis, and queries are consumed through live materialized views.

3Deploy

kalix service deploy shoppingcart myrepo/shoppingcart:latest

Kalix NPM plugin builds and publishes the image to an image repository of your choice and the Kalix CLI tool is used to deploy and manage your service on Kalix.

Kalix, as a fully managed runtime environment, removes a need for any operations and maintenance of the infrastructure and takes care of security, logging, monitoring, zero-downtime upgrades, and auto-scaling.

Getting Started Videos

SubscribeFollow
What is Kalix
1

What is Kalix

This is the first video of this nine-part video series with an overview of What is Kalix?

Setting Up a Kalix Development Environment
2

Setting Up a Kalix Development Environment

Learn how to create an account, use the Kalix CLI and console, and look at some quickstart projects.

How to Create Kalix Java Development Projects
3

How to Create Kalix Java Development Projects

Java developers get an introduction to creating and developing Kalix projects.

Intro to Design and Implementation of Kalix Services
4

Intro to Design and Implementation of Kalix Services

Here we dig into the design, development, testing, and managing of Kalix services.

Implementing Kalix Event Sourced Entities
5

Implementing Kalix Event Sourced Entities

See how easy it is to implement dynamic and effective event-sourced entity services in Java.

Implementing Kalix Key-Value Entities
6

Implementing Kalix Key-Value Entities

The more CRUD-like key-value entities are similar to event-sourced entities, and they are also more familiar to most developers.

Implementing Kalix Views
7

Implementing Kalix Views

Kalix views provide the flexibility of SQL queries of data created by event-sourced and key-value entities.

Implementing Kalix Actions
8

Implementing Kalix Actions

Actions are the glue that binds topics to entities, entities to entities, and much more.

Building Kalix Event-Driven Micro Stream Applications
9

Building Kalix Event-Driven Micro Stream Applications

Finally, we look at how entities, views, and actions, the core Kalix building blocks, are used to build Kalix micro stream/state stream applications.