Skip to content

Commit

Permalink
Added GitHub template, expanded view for messages, and switched the p…
Browse files Browse the repository at this point in the history
…rotocol for message tailing. (#3)
  • Loading branch information
nicholasnet committed Apr 21, 2023
1 parent 9426c31 commit 27074de
Show file tree
Hide file tree
Showing 32 changed files with 1,362 additions and 561 deletions.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!-- ignore-task-list-start -->
- [ ] **Breaking change?** (if so, please describe the impact and migration path for existing application instances)


<!-- ignore-task-list-end -->
**What changes did you make?** (Give an overview)

**Is there anything you'd like reviewers to focus on?**


**How Has This Been Tested?** (put an "x" (case-sensitive!) next to an item)
<!-- ignore-task-list-start -->
- [ ] No need to
- [ ] Manually (please, describe, if necessary)
- [ ] Unit checks
- [ ] Integration checks
- [ ] Covered by existing automation
<!-- ignore-task-list-end -->

**Checklist** (put an "x" (case-sensitive!) next to all the items, otherwise the build will fail)
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation (e.g. **ENVIRONMENT VARIABLES**)
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

Check out [Contributing](https://github.com/ideasbucketlabs/tansen/blob/main/documentation/CONTRIBUTING.md)
64 changes: 64 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
name: "\U0001F41E Bug report"
about: Create a bug report
title: ''
labels: status/triage, type/bug
assignees: ''

---

<!--
We will close the issue without further explanation if you don't follow this template and don't provide the information requested within this template.
Don't forget to check for existing issues/discussions regarding your proposal. We might already have it.
https://github.com/ideasbucketlabs/tansen/issues
https://github.com/ideasbucketlabs/tansen/discussions
-->

<!--
Please follow the naming conventions for bugs:
<Feature/Area/Scope> : <Compact, but specific problem summary>
Avoid generic titles, like “Topics: incorrect layout of message sorting drop-down list”. Better use something like: “Topics: Message sorting drop-down list overlaps the "Submit" button”.
-->

**Describe the bug** (Actual behavior)
<!--(A clear and concise description of what the bug is.Use a list, if there is more than one problem)-->

**Expected behavior**
<!--(A clear and concise description of what you expected to happen.)-->

**Set up**
<!--
WE MIGHT CLOSE THE ISSUE without further explanation IF YOU DON'T PROVIDE THIS INFORMATION.
How do you run the app? Please provide as much info as possible:
1. App version (docker image version or check commit hash in the top left corner in UI)
2. Helm chart version, if you use one
3. Any IAAC configs
-->


**Steps to Reproduce**
<!-- We'd like you to provide an example setup (via docker-compose, helm, etc.)
to reproduce the problem, especially with a complex setups. -->

1.

**Screenshots**
<!--
(If applicable, please add screenshots to help explain your problem)
-->


**Additional context**
<!--
Add any other context about the problem here. E.g.:
1. Are there any alternative scenarios (different data/methods/configuration/setup) you have tried?
Were they successful or same issue occurred? Please provide steps as well.
2. Related issues (if there are any).
3. Logs (if available)
4. Is there any serious impact or behaviour on the end-user because of this issue, that can be overlooked?
-->
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: "\U0001F680 Feature request"
about: Propose a new feature
title: ''
labels: status/triage, type/feature
assignees: ''

---

<!--
Don't forget to check for existing issues/discussions regarding your proposal. We might already have it.
https://github.com/ideasbucketlabs/tansen/issues
https://github.com/ideasbucketlabs/tansen/discussions
-->

### Which version of the app are you running?
<!-- Please provide docker image version or check commit hash in the top left corner in UI) -->

### Is your proposal related to a problem?

<!--
Provide a clear and concise description of what the problem is.
For example, "I'm always frustrated when..."
-->

### Describe the solution you'd like

<!--
Provide a clear and concise description of what you want to happen.
-->

### Describe alternatives you've considered

<!--
Let us know about other solutions you've tried or researched.
-->

### Additional context

<!--
Is there anything else you can add about the proposal?
You might want to link to related issues here, if you haven't already.
-->

Empty file added .github/workflows/main.yaml
Empty file.
15 changes: 15 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "PR Checklist checked"
on:
pull_request_target:
types: [opened, edited, synchronize, reopened]

jobs:
task-check:
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/task-completed-checker-action@v0.1.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
- uses: dekinderfiets/pr-description-enforcer@0.0.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p align="center">
<p align="center" style="height: 100px">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ideasbucketlabs/tansen/main/documentation/images/logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ideasbucketlabs/tansen/main/documentation/images/logo-light.svg">
<img alt="Tansen" src="https://raw.githubusercontent.com/ideasbucketlabs/tansen/main/documentation/images/logo-light.svg" width="144" height="58" style="max-width: 100%;">
<img alt="Tansen" src="https://raw.githubusercontent.com/ideasbucketlabs/tansen/main/documentation/images/logo-light.svg" width="194" height="108" style="max-width: 100%;">
</picture>
</p>

Expand All @@ -20,10 +20,10 @@
## Features

* Multi-Cluster Management — see all your clusters in one place
* Light and Dark theme based on your device preference
* Light and Dark theme based on your device preference
* View Kafka Brokers — view topic and partition assignments, controller status
* View Kafka Topics — view partition count, replication status, and custom configuration
* Topic schema Management for key and message - view, edit and delete your schema
* Topic schema Management for key and message view, edit and delete your schema
* View Consumer Groups — view per-partition parked offsets, combined and per-partition lag
* Browse Messages — browse messages with JSON, plain text, Protobuf, and Avro encoding
* Topic Configuration — create and configure new topics and edit existing one
Expand All @@ -32,9 +32,24 @@

## Getting started ##

To run Tansen for Apache Kafka, you can use either a pre-built Docker image or build it (or a jar file) yourself. For more information regarding configuration please visit [configuration page](https://github.com/ideasbucketlabs/tansen/blob/main/documentation/configuration.md).
To run Tansen for Apache Kafka, you can use either a pre-built Docker image or build it (or a jar file) yourself. For running with Docker you can use this command.
```shell
docker run -d -p 8080:8080
-e 'TANSEN.KAFKA-CLUSTERS.0.BOOTSTRAP_SERVERS=broker:9092' \
-e 'TANSEN.KAFKA-CLUSTERS.0.NAME=local' \
ideasbucket/tansen:tag
```

---
Please refer to our [configuration page](https://github.com/ideasbucketlabs/tansen/blob/main/documentation/configuration.md) for various configuration options that Tansen provides.


### Liveliness and readiness probes

Liveliness and readiness endpoint is at `/insight/health`.

Info endpoint (build info) is located at `/insight/info`.

___

## Contributing
If you're interested in contributing to Tansen, please read our [contributing docs](https://github.com/ideasbucketlabs/tansen/blob/main/documentation/CONTRIBUTING.md) **before submitting a pull request**.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@
package com.ideasbucket.tansen.entity;

import com.fasterxml.jackson.annotation.*;
import jakarta.validation.constraints.AssertFalse;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;

import java.time.Instant;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({ "offset", "partition", "timestamp" })
public final class MessageSelectionCriteria {

@JsonProperty("offset")
@NotNull(message = "Offset cannot be null")
@Min(value = 0, message = "Offset cannot be less than 0.")
private final Long offset;

@JsonProperty("partition")
@NotNull(message = "Partition cannot be null")
@Min(value = 0, message = "Partition cannot be less than 0.")
private final Integer partition;

@JsonProperty("timestamp")
Expand Down Expand Up @@ -46,18 +52,6 @@ public Instant getTimestamp() {
return timestamp;
}

@AssertFalse(message = "Invalid offset.")
@JsonIgnore
private boolean hasValidOffset() {
return this.offset != null && this.offset < 0;
}

@AssertFalse(message = "Invalid partition.")
@JsonIgnore
private boolean hasValidPartition() {
return this.partition != null && this.partition < -1;
}

@JsonIgnore
public String getCase() {
if (this.partition == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.ideasbucket.tansen.util.JsonConverter
import io.confluent.kafka.serializers.KafkaAvroDeserializer
import io.confluent.kafka.serializers.json.KafkaJsonSchemaDeserializer
import io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer
import jakarta.validation.Valid
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.asFlow
import org.apache.avro.generic.GenericData
Expand All @@ -31,6 +32,7 @@ import org.apache.kafka.common.serialization.StringDeserializer
import org.slf4j.LoggerFactory
import org.springframework.http.HttpMethod
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -45,7 +47,8 @@ import java.time.Duration
import java.util.*

@RestController
@RequestMapping("api/{clusterId:[a-zA-Z0-9][a-zA-Z0-9\\_\\-]+}/messages")
@RequestMapping("api/{clusterId:[a-zA-Z0-9][a-zA-Z0-9\\_\\-]+}/messages/{keySerde:auto|string}/{valueSerde:auto|string}")
@Validated
class MessagesController(
private val clusterService: ClusterService,
private val schemaExecutor: SchemaExecutor,
Expand All @@ -59,7 +62,9 @@ class MessagesController(
suspend fun getMessagesByTopic(
@PathVariable clusterId: String,
@PathVariable topic: String,
@RequestParam(name = "parameters", required = false) criteria: MessageSelectionCriteria?
@PathVariable keySerde: String,
@PathVariable valueSerde: String,
@Valid @RequestParam(name = "parameters", required = false) criteria: MessageSelectionCriteria?
): Flow<ObjectNode> {
val topicInformation =
topicService.getTopic(clusterId, topic)
Expand All @@ -76,8 +81,8 @@ class MessagesController(
throw UnknownTopicOrPartitionException("This server does not host this topic-partition.")
}

val valueSchemaFormat = getSchemaFormat(clusterId, "$topic-value")
val keySchemaFormat = getSchemaFormat(clusterId, "$topic-key")
val valueSchemaFormat = if (valueSerde == "string") null else getSchemaFormat(clusterId, "$topic-value")
val keySchemaFormat = if (keySerde == "string") null else getSchemaFormat(clusterId, "$topic-key")
val uniqueId = UUID.randomUUID().toString()

val properties = Properties()
Expand All @@ -94,37 +99,19 @@ class MessagesController(
properties["schema.registry.url"] = it
}

// properties[ConsumerConfig.MAX_POLL_RECORDS_CONFIG] = 20

if ((criteria !== null) && (criteria.case == "timestamp")) {
if (criteria !== null) {
properties[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "earliest"
}

val receiverOptions =
if ((criteria != null) && (criteria.case == "offset") && (criteria.partition == -1)) {
ReceiverOptions.create<Any, Any>(properties)
.commitInterval(Duration.ZERO)
.commitBatchSize(0)
.addAssignListener { partitions ->
partitions.forEach { it.seek(criteria.offset) }
}
.subscription(setOf(topic))
} else if ((criteria != null) && (criteria.case == "offset")) {
if ((criteria != null) && (criteria.case == "offset")) {
ReceiverOptions.create<Any, Any>(properties)
.commitInterval(Duration.ZERO)
.commitBatchSize(0)
.addAssignListener { partitions ->
partitions.forEach { it.seek(criteria.offset) }
}
.assignment(setOf(TopicPartition(topic, criteria.partition)))
} else if ((criteria != null) && (criteria.case == "timestamp") && (criteria.partition == -1)) {
ReceiverOptions.create<Any, Any>(properties)
.commitInterval(Duration.ZERO)
.commitBatchSize(0)
.addAssignListener { partitions ->
partitions.forEach { it.seekToTimestamp(criteria.timestamp.epochSecond) }
}
.subscription(setOf(topic))
} else if ((criteria != null) && (criteria.case == "timestamp")) {
ReceiverOptions.create<Any, Any>(properties)
.commitInterval(Duration.ZERO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.ideasbucket.tansen.controller.api

import com.fasterxml.jackson.databind.JsonNode
import com.ideasbucket.tansen.entity.MessageSelectionCriteria
import com.ideasbucket.tansen.entity.Response
import com.ideasbucket.tansen.entity.SaveSchemaRequest
import com.ideasbucket.tansen.entity.TopicSchema
Expand Down
5 changes: 2 additions & 3 deletions backend/main/resources/templates/errorTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=source-sans-pro:200,200i,400,400i,600,700,700i|source-serif-pro:200,200i,400,400i,700,700i"
rel="stylesheet"/>
<link rel="preconnect" href="https://fonts.bunny.net" crossorigin>
<link href="https://fonts.bunny.net/css2?family=Source+Sans+Pro:ital,wght@0,200;0,400;0,600;1,200;1,400;1,600&family=Source+Serif+Pro:ital,wght@0,200;0,400;0,600;0,700;1,200;1,400;1,600;1,700&display=swap" rel="stylesheet">
<link rel="icon" href="/favicon.ico"/>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon.png"
th:href="@{/assets/apple-touch-icon.png}">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.github.gradle.node.npm.task.NpmTask

plugins {
id("org.springframework.boot") version "3.0.5"
id("org.springframework.boot") version "3.0.6"
id("io.spring.dependency-management") version "1.1.0"
kotlin("jvm") version "1.7.22"
kotlin("plugin.spring") version "1.7.22"
Expand Down
8 changes: 6 additions & 2 deletions documentation/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ For frontend
```sh
cd frontend && npm run lint
```
> **Note**
> If you are creating Pull Requests please make that you run both commands `frontend` and `backend`

## Running tests

You can run the test suite using the following commands:
Expand Down Expand Up @@ -56,10 +60,10 @@ tansen.kafka-clusters.0.name=local;
tansen.kafka-clusters.0.schema_registry_url=http://localhost:8081/
SPRING_PROFILES_ACTIVE=test
```
If you are using `IntelliJ` you can use following screenshot as reference.
If you are using `IntelliJ` you can use following screenshot as a reference.
<p>
<picture>
<img alt="Tansen Environment configuration" src="https://raw.githubusercontent.com/ideasbucketlabs/tansen/main/documentation/images/environment-settings.png" width="144" height="58" style="max-width: 100%;">
<img alt="Tansen Environment configuration in IntelliJ" src="https://raw.githubusercontent.com/ideasbucketlabs/tansen/main/documentation/images/environment-settings.png" width="900" height="548" style="max-width: 100%;">
</picture>
</p>

Expand Down
Loading

0 comments on commit 27074de

Please sign in to comment.