Skip to content

Commit

Permalink
chore: update wRPC (#43)
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs authored Oct 2, 2024
1 parent ce927ea commit e8a4994
Show file tree
Hide file tree
Showing 27 changed files with 1,652 additions and 1,898 deletions.
2 changes: 1 addition & 1 deletion examples/http-server/bindings/server.wrpc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Generated by `wit-bindgen-wrpc-go` 0.8.0. DO NOT EDIT!
// Generated by `wit-bindgen-wrpc-go` 0.9.1. DO NOT EDIT!
// server package contains wRPC bindings for `server` world
package server
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by `wit-bindgen-wrpc-go` 0.8.0. DO NOT EDIT!
// Generated by `wit-bindgen-wrpc-go` 0.9.1. DO NOT EDIT!
package monotonic_clock

import (
Expand All @@ -10,7 +10,6 @@ import (
wasi__io__poll "github.com/wasmCloud/provider-sdk-go/examples/http-server/bindings/wasi/io/poll"
io "io"
slog "log/slog"
utf8 "unicode/utf8"
wrpc "wrpc.io/go"
)

Expand Down Expand Up @@ -44,33 +43,29 @@ func Now(ctx__ context.Context, wrpc__ wrpc.Invoker) (r0__ uint64, err__ error)
if cErr__ := w__.Close(); cErr__ != nil {
slog.DebugContext(ctx__, "failed to close outgoing stream", "instance", "wasi:clocks/monotonic-clock@0.2.0", "name", "now", "err", cErr__)
}
r0__, err__ = func() (Instant, error) {
v, err := func(r io.ByteReader) (uint64, error) {
var x uint64
var s uint8
for i := 0; i < 10; i++ {
slog.Debug("reading u64 byte", "i", i)
b, err := r.ReadByte()
if err != nil {
if i > 0 && err == io.EOF {
err = io.ErrUnexpectedEOF
}
return x, fmt.Errorf("failed to read u64 byte: %w", err)
}
if s == 63 && b > 0x01 {
return x, errors.New("varint overflows a 64-bit integer")
}
if b < 0x80 {
return x | uint64(b)<<s, nil
r0__, err__ = func(r io.ByteReader) (uint64, error) {
var x uint64
var s uint8
for i := 0; i < 10; i++ {
slog.Debug("reading u64 byte", "i", i)
b, err := r.ReadByte()
if err != nil {
if i > 0 && err == io.EOF {
err = io.ErrUnexpectedEOF
}
x |= uint64(b&0x7f) << s
s += 7
return x, fmt.Errorf("failed to read u64 byte: %w", err)
}
return x, errors.New("varint overflows a 64-bit integer")
}(r__)
return (Instant)(v), err
}()

if s == 63 && b > 0x01 {
return x, errors.New("varint overflows a 64-bit integer")
}
if b < 0x80 {
return x | uint64(b)<<s, nil
}
x |= uint64(b&0x7f) << s
s += 7
}
return x, errors.New("varint overflows a 64-bit integer")
}(r__)
if err__ != nil {
err__ = fmt.Errorf("failed to read result 0: %w", err__)
return
Expand All @@ -96,33 +91,29 @@ func Resolution(ctx__ context.Context, wrpc__ wrpc.Invoker) (r0__ uint64, err__
if cErr__ := w__.Close(); cErr__ != nil {
slog.DebugContext(ctx__, "failed to close outgoing stream", "instance", "wasi:clocks/monotonic-clock@0.2.0", "name", "resolution", "err", cErr__)
}
r0__, err__ = func() (Duration, error) {
v, err := func(r io.ByteReader) (uint64, error) {
var x uint64
var s uint8
for i := 0; i < 10; i++ {
slog.Debug("reading u64 byte", "i", i)
b, err := r.ReadByte()
if err != nil {
if i > 0 && err == io.EOF {
err = io.ErrUnexpectedEOF
}
return x, fmt.Errorf("failed to read u64 byte: %w", err)
}
if s == 63 && b > 0x01 {
return x, errors.New("varint overflows a 64-bit integer")
}
if b < 0x80 {
return x | uint64(b)<<s, nil
r0__, err__ = func(r io.ByteReader) (uint64, error) {
var x uint64
var s uint8
for i := 0; i < 10; i++ {
slog.Debug("reading u64 byte", "i", i)
b, err := r.ReadByte()
if err != nil {
if i > 0 && err == io.EOF {
err = io.ErrUnexpectedEOF
}
x |= uint64(b&0x7f) << s
s += 7
return x, fmt.Errorf("failed to read u64 byte: %w", err)
}
return x, errors.New("varint overflows a 64-bit integer")
}(r__)
return (Duration)(v), err
}()

if s == 63 && b > 0x01 {
return x, errors.New("varint overflows a 64-bit integer")
}
if b < 0x80 {
return x | uint64(b)<<s, nil
}
x |= uint64(b&0x7f) << s
s += 7
}
return x, errors.New("varint overflows a 64-bit integer")
}(r__)
if err__ != nil {
err__ = fmt.Errorf("failed to read result 0: %w", err__)
return
Expand Down Expand Up @@ -171,34 +162,31 @@ func SubscribeInstant(ctx__ context.Context, wrpc__ wrpc.Invoker, when uint64) (
var x uint32
var s uint
for i := 0; i < 5; i++ {
slog.Debug("reading owned resource ID length byte", "i", i)
slog.Debug("reading owned resource handle length byte", "i", i)
b, err := r.ReadByte()
if err != nil {
if i > 0 && err == io.EOF {
err = io.ErrUnexpectedEOF
}
return "", fmt.Errorf("failed to read owned resource ID length byte: %w", err)
return nil, fmt.Errorf("failed to read owned resource handle length byte: %w", err)
}
if b < 0x80 {
if i == 4 && b > 1 {
return "", errors.New("owned resource ID length overflows a 32-bit integer")
return nil, errors.New("owned resource handle length overflows a 32-bit integer")
}
x = x | uint32(b)<<s
buf := make([]byte, x)
slog.Debug("reading owned resource ID bytes", "len", x)
slog.Debug("reading owned resource handle bytes", "len", x)
_, err = r.Read(buf)
if err != nil {
return "", fmt.Errorf("failed to read owned resource ID bytes: %w", err)
}
if !utf8.Valid(buf) {
return "", errors.New("owned resource ID is not valid UTF-8")
return nil, fmt.Errorf("failed to read owned resource handle bytes: %w", err)
}
return wrpc.Own[Pollable](buf), nil
}
x |= uint32(b&0x7f) << s
s += 7
}
return "", errors.New("owned resource ID length overflows a 32-bit integer")
return nil, errors.New("owned resource handle length overflows a 32-bit integer")
}(r__)
if err__ != nil {
err__ = fmt.Errorf("failed to read result 0: %w", err__)
Expand Down Expand Up @@ -249,34 +237,31 @@ func SubscribeDuration(ctx__ context.Context, wrpc__ wrpc.Invoker, when uint64)
var x uint32
var s uint
for i := 0; i < 5; i++ {
slog.Debug("reading owned resource ID length byte", "i", i)
slog.Debug("reading owned resource handle length byte", "i", i)
b, err := r.ReadByte()
if err != nil {
if i > 0 && err == io.EOF {
err = io.ErrUnexpectedEOF
}
return "", fmt.Errorf("failed to read owned resource ID length byte: %w", err)
return nil, fmt.Errorf("failed to read owned resource handle length byte: %w", err)
}
if b < 0x80 {
if i == 4 && b > 1 {
return "", errors.New("owned resource ID length overflows a 32-bit integer")
return nil, errors.New("owned resource handle length overflows a 32-bit integer")
}
x = x | uint32(b)<<s
buf := make([]byte, x)
slog.Debug("reading owned resource ID bytes", "len", x)
slog.Debug("reading owned resource handle bytes", "len", x)
_, err = r.Read(buf)
if err != nil {
return "", fmt.Errorf("failed to read owned resource ID bytes: %w", err)
}
if !utf8.Valid(buf) {
return "", errors.New("owned resource ID is not valid UTF-8")
return nil, fmt.Errorf("failed to read owned resource handle bytes: %w", err)
}
return wrpc.Own[Pollable](buf), nil
}
x |= uint32(b&0x7f) << s
s += 7
}
return "", errors.New("owned resource ID length overflows a 32-bit integer")
return nil, errors.New("owned resource handle length overflows a 32-bit integer")
}(r__)
if err__ != nil {
err__ = fmt.Errorf("failed to read result 0: %w", err__)
Expand Down
Loading

0 comments on commit e8a4994

Please sign in to comment.