Hello World

Hello World

Authors
The Vino Team

November 18, 2021

Time for a new release! This latest build includes the vino host implementation as well as new versions of vow and vinoc.

Discord

Before we get into vino, head over to our new discord channel to ask questions, share projects, and get help with Vino, WebAssembly, or WaPC.

New features

vino

The vino executable is an implementation of the vino runtime that can run, serve, or test vino manifests. Manifests define host configuration as well as the schematics that connect WebAssembly modules and distributed systems into one service that runs anywhere.

example: Hello world

The manifest below defines a schematic called "main" with an input port named "message" that connects directly to an output port also named "message".

1
2
3
4
5
6
7
8
# yaml-language-server: $schema=https://vino.dev/schemas/manifest/v0.json
---
version: 0
network:
  schematics:
    - name: main
      connections:
        - <input>[message] => <output>[message]

Run the manifest with vino run

1
2
$ vino run echo.yaml -- --message="Hello world"
{"message":{"value":"Hello world"}}

It’s a simple program, but it’s a start. Vino also comes prewired with HTTP and GRPC support. You can serve up your fancy new echo program as a JSON API by using vino serve.

1
2
3
4
$ vino serve echo.yaml --http --http-port=8080
2021-11-18T18:24:45  INFO Host started
2021-11-18T18:24:45  INFO HTTP server bound to 127.0.0.1 on port 8080
2021-11-18T18:24:45  INFO Waiting for Ctrl-C

Test your new service with curl.

1
2
$ curl http://127.0.0.1:8080/rpc/invoke/main -d '{"message":"Hello World"}'
[{"message":{"value":"\"Hello World\""}}]

Alternately, run the manifest as a GRPC service. Note: if you don’t specify a port for either http or rpc, vino selects a random unused port automatically.

1
2
3
4
5
vino serve echo.yaml --rpc
2021-11-18T18:32:21  INFO Starting RPC server
2021-11-18T18:32:21  INFO Host started
2021-11-18T18:32:21  INFO GRPC server bound to 127.0.0.1 on port 53975
2021-11-18T18:32:21  INFO Waiting for Ctrl-C

Use vinoc to query the service on the command line or generate code for your language from the vino protobuf schema.

1
2
3
$ vinoc invoke main --port [change this to the port above] --\
   --message="Hello world"
{"message":{"value":"Hello world"}}

Providers & Connections

At its core, vino connects input arguments and output values from disparate, isolated environments – no matter if its a microservice, native code, or WebAssembly module. The manifest below shows how to pipe our inputs through a WASM binary (pulled from Vino’s OCI registry) to generate HTML as the output.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# yaml-language-server: $schema=https://vino.dev/schemas/manifest/v0.json
---
version: 0
network:
  providers:
    - namespace: markdown
      kind: WaPC
      reference: vinoreg.azurecr.io/vino/markdown
  schematics:
    - name: main
      providers:
        - markdown
      instances:
        render:
          id: markdown::render
      connections:
        - <input>[message] => render[input]
        - render[output] => <output>[message]

Run it as before to see the changes.

1
2
$ vino run markdown.yaml -- --message='# Hello world'
{"message":{"value":"<h1 id='hello_world'>Hello world</h1>\n"}}

The types of providers available in this release are:

  • WaPC: WebAssembly modules that use the WaPC protocol (what you end up with when you use yo vino).
  • GrpcUrl: A GRPC microservice specified by URL
  • Lattice: Another vino provider connected via a NATS message queue.
  • Network: A reference to another manifest (either on the file system or via OCI url)

There’s so much more to go over, so head over to our Getting Started guide to start playing around!

TAP: The Test Anything Protocol

vino and vow now come with test commands that generate TAP output. TAP is a standard, text based format for test output that has been around for decades. Now you can test components and schematics automatically by writing your test definitions as YAML.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
---
- component: render
  inputs:
    input: Hello world
  outputs:
    - { port: "output", payload: { value: "<p>Hello world</p>\n" } }
- component: render
  inputs:
    input: Hello world
  outputs:
    - { port: "output", payload: { value: "<p>This test fails</p>\n" } }

Run the test vases via vow test or vino test. Whatever manifest or module you point them to will run through the tests and print TAP output.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
$ vow test vinoreg.azurecr.io/vino/markdown test.yaml
# Test
1..6
# render
ok 1 Output port name == 'output'
ok 2 Payload value
ok 3 Tested all outputs
# render
ok 4 Output port name == 'output'
not ok 5 Payload value
# Actual: String("<p>Hello world</p>\n")
# Expected: String("<p>This test fails</p>\n")
ok 6 Tested all outputs
# Output:
# TransportWrapper { port: "output", payload: Success(MessagePack([179, 60, 112, 62, 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 60, 47, 112, 62, 10])) }
# TransportWrapper { port: "output", payload: Signal(Done) }

Next steps

This release represents a lot of work but there’s still a lot more to go. Next targets are an open source release of the runtime, node.js implementations of RPC and Lattice clients & providers, AssemblyScript & Go support in the code generator, and so much more. Make sure to follow us on twitter and join our discord channel.