question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic value instead of string

See original GitHub issue

Hi,

How can I use your library using generic models for value instead of string type. I didn’t find any example in documentation. My code works fine with string generic but it fails when I try to use custom model. Code snippet:

var config = new StreamConfig<StringSerDes, JsonSerDes>
{
    ApplicationId = "test-app",
    BootstrapServers = "localhost:9093",
    AutoOffsetReset = AutoOffsetReset.Earliest,
};

var builder = new StreamBuilder();

var personStream = builder.Stream<string, Person>("persons", new StringSerDes(), new JsonSerDes<Person>());
var locationStream = builder.Stream<string, Location>("locations", new StringSerDes(), new JsonSerDes<Location>());
var jobStream = builder.Stream<string, Job>("jobs", new StringSerDes(), new JsonSerDes<Job>());

personStream
    .SelectKey((k, v) => v.LocationId)
    .Join(locationStream.ToTable(),
        (v1, v2) => new PersonLocation
        {
            Person = v1,
            Location = v2
        })
    .SelectKey((k, v) => v.Person.JobId)
    .Join(jobStream.ToTable(), (v1, v2) => new PersonJobLocation{
        Person = v1.Person,
        Location = v1.Location,
        Job = v2
    })
    .To<StringSerDes, JsonSerDes<PersonJobLocation>>("person-job-location");

var topology = builder.Build();
var stream = new KafkaStream(topology, config);

Console.CancelKeyPress += (_, _) => {
    stream.Dispose();
};

await stream.StartAsync();

Best regards

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
LGouelleccommented, Jun 29, 2022
1reaction
LGouelleccommented, Jun 29, 2022

@PabloDeCortes, Thanks, I will have a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I constrain generic parameter to be assignable ...
I intend this generic parameter to be either a sum types of different constant strings, like "alpha"|"beta" , or an enum with string...
Read more >
How to implement a generic `ValueOf<T>` helper type in ...
The first challenge we're up against is working with an object instead of a type . So before we can do anything, we...
Read more >
How To Use Generics in TypeScript
In this code, you are creating a new generic type, which is a conditional type called GetReturnType . This generic type accepts a...
Read more >
Documentation - Generics
Here we explicitly set Type to be string as one of the arguments to the function call, denoted using the <> around the...
Read more >
Complete Guide to Using Typescript Generics
In this tutorial, you'll learn all you need to know about integrating TypeScript generics into your projects and using it to your advantage....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found