Skip to content

About

Pantopic shard client for WASI modules

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shard Client

A wazero host module, ABI and guest SDK providing a pantopic cluster shard client for WASI modules.

Host Module

First register the host module with the runtime

import (
    "github.com/tetratelabs/wazero"
    "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"

    "github.com/pantopic/ext-shard-client/host-wazero"
)

func main() {
    ctx := context.Background()
    r := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfig())
    wasi_snapshot_preview1.MustInstantiate(ctx, r)

    module := wazero_shard_client.New()
    module.Register(ctx, r)

    // ...
}

Guest SDK (Go)

Then you can import the guest SDK into your WASI module to interact with pantopic cluster shards from WASM.

package main

import (
    "unsafe"

    "github.com/pantopic/ext-shard-client/sdk-go"
)

func main() {}

var shardID uint64 = 123

//export get
func get() uint64 {
    _, data, _ := shard_client.Read(shardID, []byte(`GET /test`))
    return uint64(uintptr(unsafe.Pointer(&data[0])))<<32 + uint64(len(data))
}

//export getstale
func getstale() uint64 {
    _, data, _ := shard_client.ReadLocal(shardID, []byte(`GET /test`))
    return uint64(uintptr(unsafe.Pointer(&data[0])))<<32 + uint64(len(data))
}

//export put
func put() uint64 {
    val, _, _ := shard_client.Apply(shardID, []byte(`PUT /test {"a": 1}`))
    return val
}

//export index
func index() uint64 {
    val, _ := shard_client.Index(shardID)
    return val
}

The guest SDK has no dependencies outside the Go std lib.

Roadmap

This project is in alpha. Breaking API changes should be expected until Beta.

  • v0.0.x - Alpha
    • Stabilize API
  • v0.x.x - Beta
    • Finalize API
    • Test in production
  • v1.x.x - General Availability
    • Proven long term stability in production

About

Pantopic shard client for WASI modules

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages