npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

asyncapi-rust-ws-template

v0.2.3

Published

Rust WebSocket client template for AsyncAPI Generator

Downloads

410

Readme

AsyncAPI logo

asyncapi-rust-ws-template

npm project that converts AsyncAPI into rust websocket client crate

npm version license discord

design

  • renderer: react rather than nunjucks, for its versatility. for details, click here
  • generated code are derived as below:
    • client (server)
    • client function (channel)
    • client function logic (operation)
    • client function struct (model/schema)
  • logic cases:
    • case 0: todo
    • case 1: user transactionally send data to server
      • single [publish(v2) or receive(v3)]
      • no [subscribe(v2) or send(v3)]
      • optional single reply

contents

| name | description | | ------------------------------- | ------------------------------------------------------------------------------------------------------------- | | src/ | TypeScript source code, transpiles into template directory | | src/index.ts | transpiles to main template entry template/index.js, exposing the function for asyncapi generator command | | hooks/ | AsyncAPI hooks that cannot be processed by source | | template/ | Javascript transcribed source code for template | | test/input | local test input, AsyncAPI document | | test/output | local test output, rust client crate (git-ignore) | | package.json | NPM package definition, defines template configs | | tsconfig.json | TypeScript transpile definition, defined transcribed datas | | CHANGELOG | change log |

how to run terminal command

npm build, local YAML

asyncapi generate fromTemplate test/input/v3.yaml asyncapi-rust-ws-template -o  ~/Desktop/output

local build, local YAML

ag test/input/v3.yaml ./ -o ~/Desktop/otuput-p validate=true -p render=true

template input (AsyncAPI)

| spec | requirement | | ----------------------------------------- | ----------------------------------------------------------------------------------- | | format | AsyncAPI v2.0.0+ (supports v3 as well) | | minimum content requirement for WS client | info, servers, channels, components , can be tested with -p validate=true |

template parameters

| parameter | options | description | | ----------- | -------------------------------------------------- | ----------------------------------------------------------------------------- | | validate | true false (default) | to validate if a AsyncAPI has minimum content for generating websocket client | | render | true false (default) | to render a rust websocket client | | framework | tokio-tungstenite (default), async-tungstenite | rust websocket client framework to render |

dev setup installation

install react

npm install react

install typescript transpiler

npm install @types/react --save-devnpm install typescript @types/node --save-dev

template output (rust client crate)

The rust code generated by this template has the following structure

  • Cargo.toml // using info
  • README.md // using info
  • src/
    • lib.rs // overall library
    • client/
      • mod.rs
      • ${client}.rs // using servers, channels, operations
    • model/
      • mod.rs
      • ${message}.rs // using components

TODO

changelog: please check here

  • [x] design codegen structure
    • [x] study nunjucks vs react (decided to use react)
  • [ ] code generation
    • [x] define code structure
    • [x] websocket client function from operation
    • [x] pubsub function from channel
    • [x] fix modelina referencing other model as crate::*;
  • [ ] code testing
    • [ ] unit test

recruitment

TypeScript AsyncAPI Template Developer

I am not a TS expert, so I would love to have an expert to accelarate development for websocket genrator in the following output languages:

  • typescript, go, python

notes

  • changelog here
  • v2 and v3 terminology are flipped.
    • v2 calls operations ["publish", "subscribe"] from client's perspective
    • v3 calls operations ["receive", "send"] from server's perspective

see also