Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging v0.3.2 #48

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.3.2] - 2023-02-16

### Changes

- Fixing bug in `go/storage` where the `List` function was not appending the storage BasePath properly
- Fixing bug in `go/storage` where the `Get` function would return an error if the required scale function was not found (it now returns nil)
- Updating the `golang` compile template's `main.go` file to not have a dependency on the `scale` runtime itself

## [v0.3.1] - 2023-02-15

### Changes
Expand Down Expand Up @@ -71,7 +79,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Initial release of the Scale Runtime library.

[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.0...HEAD
[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.2...HEAD
[v0.3.2]: https://github.com/loopholelabs/scale/compare/v0.3.2
[v0.3.1]: https://github.com/loopholelabs/scale/compare/v0.3.1
[v0.3.0]: https://github.com/loopholelabs/scale/compare/v0.3.0
[v0.2.2]: https://github.com/loopholelabs/scale/compare/v0.2.2
[v0.2.1]: https://github.com/loopholelabs/scale/compare/v0.2.1
Expand Down
11 changes: 7 additions & 4 deletions go/compile/templates/main.go.templ
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main
import (
scale "{{ .path }}"
context "{{ .signature }}"
"github.com/loopholelabs/scale/go/utils"
)

// needed to satisfy compiler
Expand All @@ -17,17 +16,21 @@ func run() uint64 {
guestCtx := ctx.GuestContext()
err := guestCtx.FromReadBuffer()
if err != nil {
return utils.PackUint32(guestCtx.ErrorWriteBuffer(err))
return packUint32(guestCtx.ErrorWriteBuffer(err))
}
ctx, err = scale.Scale(ctx)
guestCtx = ctx.GuestContext()
if err != nil {
return utils.PackUint32(guestCtx.ErrorWriteBuffer(err))
return packUint32(guestCtx.ErrorWriteBuffer(err))
}
return utils.PackUint32(guestCtx.ToWriteBuffer())
return packUint32(guestCtx.ToWriteBuffer())
}

//export resize
func resize(size uint32) uint32 {
return context.Resize(size)
}

func packUint32(offset uint32, length uint32) uint64 {
return uint64(offset)<<32 | uint64(length)
}
19 changes: 14 additions & 5 deletions go/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,19 @@ func New(name string, tag string, opts ...Option) (*scalefunc.ScaleFunc, error)
switch conf.pullPolicy {
case NeverPullPolicy:
sf, _, err := st.Get(name, tag, conf.organization, "")
if err == nil {
if err != nil {
return nil, err
}
if sf != nil {
return sf, nil
}
return nil, ErrNoFunction
case IfNotPresentPullPolicy:
sf, _, err := st.Get(name, tag, conf.organization, "")
if err == nil {
if err != nil {
return nil, err
}
if sf != nil {
return sf, nil
}
var fn *models.ModelsGetFunctionResponse
Expand Down Expand Up @@ -219,7 +225,10 @@ func New(name string, tag string, opts ...Option) (*scalefunc.ScaleFunc, error)

return sf, nil
case AlwaysPullPolicy:
sf, hash, _ := st.Get(name, tag, conf.organization, "")
sf, hash, err := st.Get(name, tag, conf.organization, "")
if err != nil {
return nil, err
}
var fn *models.ModelsGetFunctionResponse
if conf.organization == DefaultOrganization {
res, err := c.Registry.GetRegistryFunctionNameTag(registry.NewGetRegistryFunctionNameTagParams().WithName(name).WithTag(tag))
Expand All @@ -234,7 +243,7 @@ func New(name string, tag string, opts ...Option) (*scalefunc.ScaleFunc, error)
}
fn = res.GetPayload()
}
if hash != "" {
if hash != "" && sf != nil {
if fn.Hash == hash {
return sf, nil
}
Expand Down Expand Up @@ -271,7 +280,7 @@ func New(name string, tag string, opts ...Option) (*scalefunc.ScaleFunc, error)
return nil, fmt.Errorf("failed to decode retrieved scale function %s/%s:%s: %w", conf.organization, name, tag, err)
}

if hash != "" {
if hash != "" && sf != nil {
err = st.Delete(name, tag, conf.organization, hash)
if err != nil {
return nil, fmt.Errorf("failed to delete existing scale function %s/%s:%s: %w", conf.organization, name, tag, err)
Expand Down
8 changes: 4 additions & 4 deletions go/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ func (s *Storage) Get(name string, tag string, org string, hash string) (*scalef
}

if len(matches) == 0 {
return nil, "", fmt.Errorf("no matches found for %s:%s", name, tag)
return nil, "", nil
}

if len(matches) > 1 {
return nil, "", fmt.Errorf("multiple matches found for %s:%s", name, tag)
return nil, "", fmt.Errorf("multiple matches found for %s/%s:%s", org, name, tag)
}

sf, err := scalefunc.Read(matches[0])
Expand Down Expand Up @@ -123,9 +123,9 @@ func (s *Storage) List() ([]*scalefunc.ScaleFunc, error) {
if entry.IsDir() {
continue
}
scaleFunc, err := scalefunc.Read(entry.Name())
scaleFunc, err := scalefunc.Read(s.fullPath(entry.Name()))
if err != nil {
return nil, fmt.Errorf("failed to decode scale function %s: %w", entry.Name(), err)
return nil, fmt.Errorf("failed to decode scale function %s: %w", s.fullPath(entry.Name()), err)
}
scaleFuncEntries = append(scaleFuncEntries, scaleFunc)
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loopholelabs/scale-ts",
"version": "0.3.1",
"version": "0.3.2",
"description": "Scale is a highly-performant WebAssembly function runtime that enables composable, language-agnostic software development.",
"source": "./ts/index.ts",
"main": "dist/main.js",
Expand Down