I've been working with Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Template} from '@hexlabs/kloudformation-ts'; | |
import {join, joinWith, Value, Base64Fn} from '@hexlabs/kloudformation-ts/dist/kloudformation/Value'; | |
import {AWS} from '@hexlabs/kloudformation-ts/dist/kloudformation/aws'; | |
import {InternetGateway} from '@hexlabs/kloudformation-ts/dist/aws/ec2/InternetGateway'; | |
import {VPC} from '@hexlabs/kloudformation-ts/dist/aws/ec2/VPC'; | |
import {VPCGatewayAttachment} from '@hexlabs/kloudformation-ts/dist/aws/ec2/VPCGatewayAttachment'; | |
import {RouteTable} from '@hexlabs/kloudformation-ts/dist/aws/ec2/RouteTable'; | |
import {SecurityGroup} from '@hexlabs/kloudformation-ts/dist/aws/ec2/SecurityGroup'; | |
import {NatGateway} from '@hexlabs/kloudformation-ts/dist/aws/ec2/NatGateway'; | |
import {Subnet} from '@hexlabs/kloudformation-ts/dist/aws/ec2/Subnet'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def trace[U, V]( | |
functionName: String | |
)(func: U => V)(implicit txnExecutionContext: TxnExecutionContext): U => V = | |
new Function1[U, V] { | |
// set functionName, call trace async here | |
def apply(u: U): V = { | |
txnExecutionContext.token.link() | |
func(u) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> queryUser(s: T?) = | |
Either.fromNullable(s).mapLeft { "unknown" } | |
data class Person(val name: String, val age: Int) | |
val ePerson: Either<String, Person> = Either.applicative<String>().mapN( | |
queryUser("name"), | |
queryUser(10) | |
) { (name, age) -> Person(name, age) }.fix() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{iter::FromIterator, rc::Rc}; | |
#[derive(Eq, PartialEq, Debug, Ord, PartialOrd, Clone)] | |
struct Node<T> { | |
elem: T, | |
next: Link<T>, | |
} | |
#[derive(Eq, PartialEq, Debug, Ord, PartialOrd, Clone)] | |
pub struct List<T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function todoRoutes(todoService: TodoService): Handler { | |
return router([ | |
bind("/{id}", router([ | |
bind(HttpMethod.GET, async request => { | |
const id = requiredPathParam(request, "id"); | |
const todoEntry = todoService.fetch(id); | |
return (todoEntry) | |
? { statusCode: 200, body: JSON.stringify(todoEntry) } | |
: { statusCode: 404, body: '' }; | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Location(val location: String, val since: String, val till: String) | |
val searchDate = LocalDate.now() | |
locations.filter { location -> | |
searchDate.isAfter(LocalDate.parse(location.since, DateTimeFormatter.ISO_DATE)) && | |
searchDate.isBefore(LocalDate.parse(location.since, DateTimeFormatter.ISO_DATE)) | |
}.groupBy { it.location } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arrow.Kind | |
import arrow.core.Either | |
import arrow.fx.IO | |
import arrow.fx.ForIO | |
import arrow.fx.Queue | |
import arrow.fx.Timer | |
import arrow.fx.fix | |
import arrow.fx.handleErrorWith | |
import arrow.fx.QueueShutdown | |
import arrow.fx.extensions.fx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[error] /.../src/test/scala/admin/repository/ProductServiceSqlTest.scala:18:14: type mismatch; | |
[error] found : cats.effect.Resource[cats.effect.IO,doobie.hikari.HikariTransactor[cats.effect.IO]] | |
[error] (which expands to) cats.effect.Resource[cats.effect.IO,doobie.util.transactor.Transactor[cats.effect.IO]{type A = com.zaxxer.hikari.HikariDataSource}] | |
[error] required: cats.effect.Resource[F,doobie.hikari.HikariTransactor[F]] | |
[error] (which expands to) cats.effect.Resource[F,doobie.util.transactor.Transactor[F]{type A = com.zaxxer.hikari.HikariDataSource}] | |
[error] xa <- transactor(dbConf) | |
[error] ^ | |
[info] cats.effect.Resource[cats.effect.IO,doobie.hikari.HikariTransactor[cats.effect.IO]] <: cats.effect.Resource[F,doobie.hikari.HikariTransactor[F]]? | |
[info] F[_] <: cats.effect.IO[_]? | |
[info] false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package co.brightcog.validation | |
import arrow.core.* | |
import arrow.data.* | |
import arrow.typeclasses.* | |
sealed class Failure { | |
data class EmptyString(val fieldName: String) : Failure() | |
data class InvalidCity(val fieldName: String) : Failure() |
NewerOlder