Skip to content

Commit c108531

Browse files
authored
Updated dependencies and Go version (#29)
1 parent 6331581 commit c108531

File tree

12 files changed

+91
-116
lines changed

12 files changed

+91
-116
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go 1.x
1717
uses: actions/setup-go@v2
1818
with:
19-
go-version: ^1.16
19+
go-version: ^1.19
2020
id: go
2121

2222
- name: Check out code into the Go module directory

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v2
1818
with:
19-
go-version: ^1.16
19+
go-version: ^1.19
2020
- name: Set up env vars
2121
run: |
2222
export FERRET_VERSION=$(sh versions.sh ferret)

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,5 @@ bin
109109
*.log
110110
*.orig
111111
dist
112-
coverage.txt
112+
coverage.txt
113+
.private

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:alpine AS builder
1+
FROM golang:1.19-alpine AS builder
22

33
# Install git.
44
# Git is required for fetching the dependencies.
@@ -13,7 +13,7 @@ COPY . .
1313
RUN CGO_ENABLED=0 GOOS=linux make compile
1414

1515
# Build the final container. And install
16-
FROM montferret/chromium:99.0.4844.0 as runner
16+
FROM montferret/chromium:106.0.5249.0 as runner
1717

1818
RUN apt-get update && apt-get install -y dumb-init
1919

Dockerfile.release

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM montferret/chromium:99.0.4844.0
1+
FROM montferret/chromium:106.0.5249.0
22

33
RUN apt-get update && apt-get install -y dumb-init ca-certificates
44

go.mod

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
module github.com/MontFerret/worker
22

3-
go 1.17
3+
go 1.19
44

55
require (
6-
github.com/MontFerret/ferret v0.16.6
6+
github.com/MontFerret/ferret v0.16.7
77
github.com/go-waitfor/waitfor v1.0.0
88
github.com/go-waitfor/waitfor-http v1.0.0
9-
github.com/hashicorp/golang-lru v0.5.4
10-
github.com/labstack/echo/v4 v4.6.3
9+
github.com/hashicorp/golang-lru/v2 v2.0.1
10+
github.com/labstack/echo/v4 v4.9.1
1111
github.com/namsral/flag v1.7.4-pre
1212
github.com/pkg/errors v0.9.1
13-
github.com/rs/zerolog v1.26.1
14-
github.com/ziflex/lecho/v3 v3.1.0
13+
github.com/rs/zerolog v1.28.0
14+
github.com/ziflex/lecho/v3 v3.3.0
1515
)
1616

1717
require (
1818
github.com/PuerkitoBio/goquery v1.8.0 // indirect
1919
github.com/andybalholm/cascadia v1.3.1 // indirect
20-
github.com/antchfx/htmlquery v1.2.4 // indirect
21-
github.com/antchfx/xpath v1.2.0 // indirect
20+
github.com/antchfx/htmlquery v1.2.5 // indirect
21+
github.com/antchfx/xpath v1.2.1 // indirect
2222
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211211185417-43fb4c2dbe28 // indirect
2323
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
2424
github.com/corpix/uarand v0.1.1 // indirect
@@ -27,18 +27,18 @@ require (
2727
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
2828
github.com/gorilla/css v1.0.0 // indirect
2929
github.com/gorilla/websocket v1.4.2 // indirect
30-
github.com/labstack/gommon v0.3.1 // indirect
30+
github.com/labstack/gommon v0.4.0 // indirect
3131
github.com/mafredri/cdp v0.32.0 // indirect
32-
github.com/mattn/go-colorable v0.1.11 // indirect
32+
github.com/mattn/go-colorable v0.1.12 // indirect
3333
github.com/mattn/go-isatty v0.0.14 // indirect
3434
github.com/sethgrid/pester v1.1.0 // indirect
3535
github.com/valyala/bytebufferpool v1.0.0 // indirect
3636
github.com/valyala/fasttemplate v1.2.1 // indirect
37-
github.com/wI2L/jettison v0.7.3 // indirect
38-
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e // indirect
37+
github.com/wI2L/jettison v0.7.4 // indirect
38+
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
3939
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
4040
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
41-
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
41+
golang.org/x/sys v0.0.0-20220318055525-2edf467146b5 // indirect
4242
golang.org/x/text v0.3.7 // indirect
4343
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
4444
)

go.sum

+30-70
Large diffs are not rendered by default.

internal/storage/cache.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package storage
22

33
import (
4-
"github.com/hashicorp/golang-lru"
4+
"github.com/MontFerret/ferret/pkg/runtime"
5+
"github.com/hashicorp/golang-lru/v2"
56

67
"github.com/MontFerret/worker/pkg/caching"
78
)
89

910
type InMemoryCache struct {
10-
store *lru.Cache
11+
store *lru.Cache[string, *runtime.Program]
1112
}
1213

13-
func NewCache(opts ...caching.Option) (caching.Cache, error) {
14+
func NewCache(opts ...caching.Option) (caching.Cache[*runtime.Program], error) {
1415
options := caching.NewOptions(opts...)
1516

16-
store, err := lru.New(int(options.Size))
17+
store, err := lru.New[string, *runtime.Program](int(options.Size))
1718

1819
if err != nil {
1920
return nil, err
@@ -22,14 +23,14 @@ func NewCache(opts ...caching.Option) (caching.Cache, error) {
2223
return &InMemoryCache{store}, nil
2324
}
2425

25-
func (cache *InMemoryCache) Set(key, value interface{}) {
26+
func (cache *InMemoryCache) Set(key string, value *runtime.Program) {
2627
cache.store.Add(key, value)
2728
}
2829

29-
func (cache *InMemoryCache) Get(key interface{}) (interface{}, bool) {
30+
func (cache *InMemoryCache) Get(key string) (*runtime.Program, bool) {
3031
return cache.store.Get(key)
3132
}
3233

33-
func (cache *InMemoryCache) Contains(key interface{}) bool {
34+
func (cache *InMemoryCache) Contains(key string) bool {
3435
return cache.store.Contains(key)
3536
}

pkg/caching/cache.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package caching
22

3-
type Cache interface {
4-
Set(key, value interface{})
3+
type Cache[T any] interface {
4+
Set(key string, value T)
55

6-
Get(key interface{}) (interface{}, bool)
6+
Get(key string) (T, bool)
77

8-
Contains(key interface{}) bool
8+
Contains(key string) bool
99
}

pkg/worker/options.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package worker
33
import (
44
"fmt"
55

6+
"github.com/MontFerret/ferret/pkg/runtime"
67
"github.com/MontFerret/ferret/pkg/runtime/core"
78
"github.com/MontFerret/worker/pkg/caching"
89
)
@@ -17,7 +18,7 @@ type (
1718
functions []core.Functions
1819
noStdlib bool
1920
cdp CDPSettings
20-
cache caching.Cache
21+
cache caching.Cache[*runtime.Program]
2122
}
2223

2324
Option func(opts *Options)
@@ -59,7 +60,7 @@ func WithCustomCDP(cdp CDPSettings) Option {
5960
}
6061
}
6162

62-
func WithCache(cache caching.Cache) Option {
63+
func WithCache(cache caching.Cache[*runtime.Program]) Option {
6364
return func(opts *Options) {
6465
opts.cache = cache
6566
}

pkg/worker/worker.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
type Worker struct {
1818
comp *compiler.Compiler
1919
drivers []drivers.Driver
20-
cache caching.Cache
20+
cache caching.Cache[*runtime.Program]
2121
}
2222

2323
// New returns Worker without file system access.
@@ -87,7 +87,7 @@ func (w *Worker) compiledOrCached(text string) (*runtime.Program, error) {
8787
found, isFound := w.cache.Get(text)
8888

8989
if isFound && found != nil {
90-
program = found.(*runtime.Program)
90+
program = found
9191
}
9292
}
9393

reference/ferret-worker.yaml

+24-12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ paths:
6262
description: OK
6363
schema:
6464
$ref: '#/definitions/QueryResult'
65+
'400':
66+
description: Bad Request
67+
schema:
68+
$ref: '#/definitions/Error'
69+
'500':
70+
description: Internal Server Error
71+
schema:
72+
$ref: '#/definitions/Error'
6573
description: Execute a query.
6674
parameters:
6775
- in: body
@@ -124,15 +132,19 @@ definitions:
124132
- text
125133
QueryResult:
126134
title: Result
127-
anyOf:
128-
- type: object
129-
- type: array
130-
items: {}
131-
- type: string
132-
properties: {}
133-
- type: number
134-
properties: {}
135-
- type: boolean
136-
properties: {}
137-
- properties: {}
138-
x-nullable: true
135+
type:
136+
- object
137+
- string
138+
- number
139+
- integer
140+
- boolean
141+
- array
142+
x-nullable: true
143+
Error:
144+
title: Error
145+
type: object
146+
properties:
147+
error:
148+
type: string
149+
required:
150+
- error

0 commit comments

Comments
 (0)