GithubHelp home page GithubHelp logo

Async communication about kun HOT 17 CLOSED

russellluo avatar russellluo commented on July 17, 2024
Async communication

from kun.

Comments (17)

RussellLuo avatar RussellLuo commented on July 17, 2024

Hi @gedw99, thank you for the useful information!

I do know NATS, but have little experience with it. As for the asynchronous specification, I've used CloudEvents, but have no idea about AsyncAPI, which is awesome!

Your idea of generating AsyncAPI document sounds interesting. Is there any example in your mind? What does the input and output of the generator look like?

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

Well cloud event is agnostic and uses nats if you want.

there are no examples of asyncapi, but its not really needed because the core part is all golang and really well done from what i can see

https://github.com/orgs/asyncapi/repositories?q=&type=&language=go&sort=

https://github.com/asyncapi/event-gateway currently uses Kafka, but i think adding nats is not hard actually.

NATS is such a simple api. Their go.mod shows it uses watermill, the nats watermill is already there that can be integrated: https://github.com/ThreeDotsLabs/watermill-nats

Also from the go.mod you can see the gateway uses this parser github.com/asyncapi/parser-go, which i think is parsing the schema spec.

https://github.com/asyncapi/spec-json-schemas holds the spec versions. Pretty simple.

https://github.com/asyncapi/converter-go is just a spec upgrader.

The way this golang stuff hangs together is pretty clean IMHO.

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

All the other repos in async api is all just for JS developers.

Its mostly Tons of complex tooling so as to give them a web based GUI.

Not needed in many ways. But there is a developer wants it.

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

i started a discussion here: asyncapi-archived-repos/event-gateway#81

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

Also the gateway can then be part of the Caddy proxy if you wanted. Just saw that you have one.

So then all Sync and async operations can be described from the Spec and used by caddy to forward everything to the correct Service.

Could also of course be just run inline.

Your way of using annotations means that the spec is generated

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

Its kind of cool because you can embed the caddway and NATS Jetstream into a simple binary IF you want OR you can scale it out. Cant do that with kafka.

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

ah i just realised that there are bindings.

Its a late bound architecture...

https://github.com/asyncapi/bindings/blob/master/nats/README.md

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

Found an example: https://github.com/asyncapi/ts-nats-template

they lean towards generating JS based clients.

but generating nats or other golang client is possible of course.

from kun.

RussellLuo avatar RussellLuo commented on July 17, 2024

Sounds great! Welcome to add the AsyncAPI document generator you expected ;)

Just FYI, here are the generation methods currently used in kok:

  • Runtime reflection (based on reflect) for generating OpenAPI Specification
    • We can not use static analysis here, since the requests and responses may be manipulated dynamically by custom HTTP codecs.
  • Static analysis (based on go/packages) for generating Protocol Buffers

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

sorry about not following up.. Got snowed under with other work stuff.

I realised after messing around with ideas that the most powerful thing that i can do with kun is to parse golang structs to JSONSchema. Then at runtime i can use these JSON Schemas for runtime checks and events and a myriad of things.

Its nice too because you work in Golang, gen your JSONSchema that represent those structs. Forward engineering.
Then you can build systems that are loosely coupled at runtime.

from kun.

RussellLuo avatar RussellLuo commented on July 17, 2024

Hi @gedw99, here is an attempt to add support for generating handlers for Event Subscribers #27. (Does not yet support generating AsyncAPI documentation.)

I realised after messing around with ideas that the most powerful thing that i can do with kun is to parse golang structs to JSONSchema.

Sounds good! Then it's recommended to use static analysis (based on go/packages). Maybe you could take a look at the implementation of the gRPC parser :)

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

Hey Hey

Looks great. Whats the transport ? I assume websockets ? I ask because i want to be able to compile the generated golang client so that the GUI works with GIOUO: https://github.com/gioui. nhooyr.io/websocket works with GIOUI.

here is a graphql client that uses it and works with GIOUI just to give you an example of what i mean: https://github.com/hasura/go-graphql-client

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

About AsyncAPI. You want to use their system to run it ?

from kun.

RussellLuo avatar RussellLuo commented on July 17, 2024

Whats the transport ? I assume websockets ?

The current design is meant to be generic, so there's no assumption about the transport for now. We currently use Kafka, but any other transport can use the generated handlers.

About AsyncAPI. You want to use their system to run it ?

Not intend to do so. But I think it's specially suitable for generating documentation (much like OpenAPI).

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

I don’t us Kafka . Is it possible you could add a Kafka docker to the repo to get me going ? As well as a make file to make it obvious how to use it

from kun.

RussellLuo avatar RussellLuo commented on July 17, 2024

As mentioned above, any transport/broker (e.g. WebSocket, Kafka, Redis or even HTTP) can use the generated handlers. As an example, eventsvc just use a simple Go program to trigger the handlers.

from kun.

gedw99 avatar gedw99 commented on July 17, 2024

thanks the eventsrc example helps..

from kun.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.