server update
This commit is contained in:
parent
1ff168a931
commit
ee8ffc2abd
12 changed files with 214 additions and 1996 deletions
103
server/go.mod
103
server/go.mod
|
@ -1,65 +1,65 @@
|
||||||
module git.kmsign.ru/royalcat/tstor/server
|
module git.kmsign.ru/royalcat/tstor/server
|
||||||
|
|
||||||
go 1.23.0
|
go 1.23.8
|
||||||
|
|
||||||
toolchain go1.24.1
|
toolchain go1.24.2
|
||||||
|
|
||||||
// replace github.com/iceber/iouring-go => github.com/royalcat/iouring-go v0.0.0-20240925200811-286062ac1b23
|
// replace github.com/iceber/iouring-go => github.com/royalcat/iouring-go v0.0.0-20240925200811-286062ac1b23
|
||||||
|
|
||||||
// replace github.com/chenzhuoyu/iasm v0.9.0 => github.com/cloudwego/iasm v0.2.0
|
// replace github.com/chenzhuoyu/iasm v0.9.0 => github.com/cloudwego/iasm v0.2.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/99designs/gqlgen v0.17.70
|
github.com/99designs/gqlgen v0.17.72
|
||||||
github.com/billziss-gh/cgofuse v1.5.0
|
github.com/billziss-gh/cgofuse v1.5.0
|
||||||
github.com/cespare/xxhash/v2 v2.3.0
|
github.com/cespare/xxhash/v2 v2.3.0
|
||||||
github.com/dgraph-io/badger/v4 v4.5.0
|
github.com/dgraph-io/badger/v4 v4.6.0
|
||||||
github.com/go-chi/stampede v0.6.0
|
github.com/go-chi/stampede v0.6.0
|
||||||
github.com/go-git/go-billy/v5 v5.6.1
|
github.com/go-git/go-billy/v5 v5.6.2
|
||||||
github.com/gofrs/uuid/v5 v5.1.0
|
github.com/gofrs/uuid/v5 v5.3.2
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/goware/singleflight v0.2.0
|
github.com/goware/singleflight v0.3.0
|
||||||
github.com/grafana/otel-profiling-go v0.5.1
|
github.com/grafana/otel-profiling-go v0.5.1
|
||||||
github.com/grafana/pyroscope-go v1.1.2
|
github.com/grafana/pyroscope-go v1.2.2
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||||
github.com/knadh/koanf/parsers/yaml v0.1.0
|
github.com/knadh/koanf/parsers/yaml v1.0.0
|
||||||
github.com/knadh/koanf/providers/env v0.1.0
|
github.com/knadh/koanf/providers/env v1.1.0
|
||||||
github.com/knadh/koanf/providers/file v0.1.0
|
github.com/knadh/koanf/providers/file v1.2.0
|
||||||
github.com/knadh/koanf/providers/structs v0.1.0
|
github.com/knadh/koanf/providers/structs v1.0.0
|
||||||
github.com/knadh/koanf/v2 v2.1.2
|
github.com/knadh/koanf/v2 v2.2.0
|
||||||
github.com/labstack/echo-contrib v0.17.1
|
github.com/labstack/echo-contrib v0.17.3
|
||||||
github.com/labstack/echo/v4 v4.12.0
|
github.com/labstack/echo/v4 v4.13.3
|
||||||
github.com/prometheus/client_golang v1.20.4
|
github.com/prometheus/client_golang v1.22.0
|
||||||
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93
|
github.com/rasky/go-xdr v0.0.0-20170124162913-1a41d1a06c93
|
||||||
github.com/ravilushqa/otelgqlgen v0.15.0
|
github.com/ravilushqa/otelgqlgen v0.17.0
|
||||||
github.com/royalcat/btrgo v0.0.0-20240318160410-19bd27154450
|
github.com/royalcat/btrgo v0.0.0-20240318160410-19bd27154450
|
||||||
github.com/royalcat/ctxio v0.0.0-20240602084623-009bd79b3176
|
github.com/royalcat/ctxio v0.0.0-20240602084623-009bd79b3176
|
||||||
github.com/royalcat/ctxprogress v0.0.0-20240614113930-3cc5bb935bff
|
github.com/royalcat/ctxprogress v0.0.0-20240614113930-3cc5bb935bff
|
||||||
github.com/royalcat/kv v0.0.0-20240723215915-954e36a2491d
|
github.com/royalcat/kv v0.0.0-20240723215915-954e36a2491d
|
||||||
github.com/royalcat/kv/kvbadger v0.0.0-20240723215915-954e36a2491d
|
github.com/royalcat/kv/kvbadger v0.0.0-20240723215915-954e36a2491d
|
||||||
github.com/rs/zerolog v1.32.0
|
github.com/rs/zerolog v1.34.0
|
||||||
github.com/samber/slog-multi v1.0.2
|
github.com/samber/slog-multi v1.4.0
|
||||||
github.com/samber/slog-zerolog v1.0.0
|
github.com/samber/slog-zerolog v1.0.0
|
||||||
github.com/sourcegraph/conc v0.3.0
|
github.com/sourcegraph/conc v0.3.0
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.10.0
|
||||||
github.com/urfave/cli/v2 v2.27.6
|
github.com/urfave/cli/v2 v2.27.6
|
||||||
github.com/vektah/gqlparser/v2 v2.5.23
|
github.com/vektah/gqlparser/v2 v2.5.25
|
||||||
github.com/willscott/go-nfs-client v0.0.0-20240104095149-b44639837b00
|
github.com/willscott/go-nfs-client v0.0.0-20240104095149-b44639837b00
|
||||||
github.com/willscott/memphis v0.0.0-20210922141505-529d4987ab7e
|
github.com/willscott/memphis v0.0.0-20241203204924-a148a489d367
|
||||||
go.opentelemetry.io/contrib/bridges/otelslog v0.10.0
|
go.opentelemetry.io/contrib/bridges/otelslog v0.10.0
|
||||||
go.opentelemetry.io/otel v1.35.0
|
go.opentelemetry.io/otel v1.35.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.11.0
|
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.11.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.31.0
|
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.35.0
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0
|
||||||
go.opentelemetry.io/otel/exporters/prometheus v0.53.0
|
go.opentelemetry.io/otel/exporters/prometheus v0.57.0
|
||||||
go.opentelemetry.io/otel/metric v1.35.0
|
go.opentelemetry.io/otel/metric v1.35.0
|
||||||
go.opentelemetry.io/otel/sdk v1.35.0
|
go.opentelemetry.io/otel/sdk v1.35.0
|
||||||
go.opentelemetry.io/otel/sdk/log v0.11.0
|
go.opentelemetry.io/otel/sdk/log v0.11.0
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.34.0
|
go.opentelemetry.io/otel/sdk/metric v1.35.0
|
||||||
go.opentelemetry.io/otel/trace v1.35.0
|
go.opentelemetry.io/otel/trace v1.35.0
|
||||||
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
|
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0
|
||||||
golang.org/x/net v0.38.0
|
golang.org/x/net v0.39.0
|
||||||
golang.org/x/sync v0.12.0
|
golang.org/x/sync v0.13.0
|
||||||
golang.org/x/sys v0.31.0
|
golang.org/x/sys v0.32.0
|
||||||
)
|
)
|
||||||
|
|
||||||
replace google.golang.org/genproto => google.golang.org/genproto v0.0.0-20250324211829-b45e905df463
|
replace google.golang.org/genproto => google.golang.org/genproto v0.0.0-20250324211829-b45e905df463
|
||||||
|
@ -68,25 +68,23 @@ require (
|
||||||
github.com/agnivade/levenshtein v1.2.1 // indirect
|
github.com/agnivade/levenshtein v1.2.1 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
|
||||||
github.com/cyphar/filepath-securejoin v0.3.6 // indirect
|
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/dgraph-io/ristretto/v2 v2.0.0 // indirect
|
github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/fatih/structs v1.1.0 // indirect
|
github.com/fatih/structs v1.1.0 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
github.com/google/flatbuffers v25.2.10+incompatible // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
|
||||||
github.com/google/flatbuffers v24.3.25+incompatible // indirect
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 // indirect
|
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 // indirect
|
||||||
github.com/gorilla/websocket v1.5.1 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
|
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
||||||
github.com/klauspost/compress v1.17.11 // indirect
|
github.com/klauspost/compress v1.18.0 // indirect
|
||||||
github.com/knadh/koanf/maps v0.1.1 // indirect
|
github.com/knadh/koanf/maps v0.1.2 // indirect
|
||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
@ -98,30 +96,29 @@ require (
|
||||||
github.com/polydawn/go-timeless-api v0.0.0-20220821201550-b93919e12c56 // indirect
|
github.com/polydawn/go-timeless-api v0.0.0-20220821201550-b93919e12c56 // indirect
|
||||||
github.com/polydawn/refmt v0.89.0 // indirect
|
github.com/polydawn/refmt v0.89.0 // indirect
|
||||||
github.com/polydawn/rio v0.0.0-20220823181337-7c31ad9831a4 // indirect
|
github.com/polydawn/rio v0.0.0-20220823181337-7c31ad9831a4 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.2 // indirect
|
||||||
github.com/prometheus/common v0.60.0 // indirect
|
github.com/prometheus/common v0.63.0 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.16.1 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/samber/lo v1.47.0 // indirect
|
github.com/samber/lo v1.49.1 // indirect
|
||||||
github.com/sosodev/duration v1.3.1 // indirect
|
github.com/sosodev/duration v1.3.1 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
github.com/warpfork/go-errcat v0.0.0-20180917083543-335044ffc86e // indirect
|
github.com/warpfork/go-errcat v0.0.0-20180917083543-335044ffc86e // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||||
go.opentelemetry.io/contrib v1.26.0 // indirect
|
go.opentelemetry.io/contrib v1.35.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
|
||||||
go.opentelemetry.io/otel/log v0.11.0 // indirect
|
go.opentelemetry.io/otel/log v0.11.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
||||||
go.uber.org/multierr v1.10.0 // indirect
|
go.uber.org/multierr v1.11.0 // indirect
|
||||||
golang.org/x/crypto v0.36.0 // indirect
|
golang.org/x/crypto v0.37.0 // indirect
|
||||||
golang.org/x/mod v0.24.0 // indirect
|
golang.org/x/mod v0.24.0 // indirect
|
||||||
golang.org/x/text v0.23.0 // indirect
|
golang.org/x/text v0.24.0 // indirect
|
||||||
golang.org/x/time v0.10.0 // indirect
|
golang.org/x/time v0.11.0 // indirect
|
||||||
golang.org/x/tools v0.31.0 // indirect
|
golang.org/x/tools v0.32.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
|
||||||
google.golang.org/grpc v1.71.1 // indirect
|
google.golang.org/grpc v1.71.1 // indirect
|
||||||
google.golang.org/protobuf v1.36.6 // indirect
|
google.golang.org/protobuf v1.36.6 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
|
1911
server/go.sum
1911
server/go.sum
File diff suppressed because it is too large
Load diff
|
@ -24,20 +24,22 @@ type Cache[K comparable, V any] struct {
|
||||||
callGroup singleflight.Group[K, V]
|
callGroup singleflight.Group[K, V]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache[K, V]) Get(ctx context.Context, key K, fn singleflight.DoFunc[V]) (V, error) {
|
type DoFunc[V any] func() (V, error)
|
||||||
|
|
||||||
|
func (c *Cache[K, V]) Get(ctx context.Context, key K, fn DoFunc[V]) (V, error) {
|
||||||
return c.get(ctx, key, false, fn)
|
return c.get(ctx, key, false, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache[K, V]) GetFresh(ctx context.Context, key K, fn singleflight.DoFunc[V]) (V, error) {
|
func (c *Cache[K, V]) GetFresh(ctx context.Context, key K, fn DoFunc[V]) (V, error) {
|
||||||
return c.get(ctx, key, true, fn)
|
return c.get(ctx, key, true, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache[K, V]) Set(ctx context.Context, key K, fn singleflight.DoFunc[V]) (V, bool, error) {
|
func (c *Cache[K, V]) Set(ctx context.Context, key K, fn DoFunc[V]) (V, bool, error) {
|
||||||
v, err, shared := c.callGroup.Do(key, c.set(key, fn))
|
v, err, shared := c.callGroup.Do(key, c.set(key, fn))
|
||||||
return v, shared, err
|
return v, shared, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache[K, V]) get(ctx context.Context, key K, freshOnly bool, fn singleflight.DoFunc[V]) (V, error) {
|
func (c *Cache[K, V]) get(ctx context.Context, key K, freshOnly bool, fn DoFunc[V]) (V, error) {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
val, ok := c.values.Get(key)
|
val, ok := c.values.Get(key)
|
||||||
c.mu.RUnlock()
|
c.mu.RUnlock()
|
||||||
|
@ -61,8 +63,8 @@ func (c *Cache[K, V]) get(ctx context.Context, key K, freshOnly bool, fn singlef
|
||||||
return v, err
|
return v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache[K, V]) set(key K, fn singleflight.DoFunc[V]) singleflight.DoFunc[V] {
|
func (c *Cache[K, V]) set(key K, fn DoFunc[V]) DoFunc[V] {
|
||||||
return singleflight.DoFunc[V](func() (V, error) {
|
return DoFunc[V](func() (V, error) {
|
||||||
val, err := fn()
|
val, err := fn()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return val, err
|
return val, err
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
|
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
|
||||||
|
"github.com/99designs/gqlgen/graphql"
|
||||||
"github.com/knadh/koanf/v2"
|
"github.com/knadh/koanf/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,3 +16,8 @@ type Daemon interface {
|
||||||
GetFS(ctx context.Context, sourcePath string, file vfs.File) (vfs.Filesystem, error)
|
GetFS(ctx context.Context, sourcePath string, file vfs.File) (vfs.Filesystem, error)
|
||||||
Close(ctx context.Context) error
|
Close(ctx context.Context) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DaemonWithGraphQL interface {
|
||||||
|
Daemon
|
||||||
|
GraphQLSchema() graphql.ExecutableSchema
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ type Dir interface {
|
||||||
IsFsEntry()
|
IsFsEntry()
|
||||||
IsDir()
|
IsDir()
|
||||||
GetName() string
|
GetName() string
|
||||||
GetEntries() []FsEntry
|
// GetEntries() []FsEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
type FsEntry interface {
|
type FsEntry interface {
|
||||||
|
|
|
@ -44,8 +44,6 @@ type Config struct {
|
||||||
type ResolverRoot interface {
|
type ResolverRoot interface {
|
||||||
Mutation() MutationResolver
|
Mutation() MutationResolver
|
||||||
Query() QueryResolver
|
Query() QueryResolver
|
||||||
ResolverFS() ResolverFSResolver
|
|
||||||
SimpleDir() SimpleDirResolver
|
|
||||||
Subscription() SubscriptionResolver
|
Subscription() SubscriptionResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,12 +105,6 @@ type QueryResolver interface {
|
||||||
Plugins(ctx context.Context) ([]*model.Plugin, error)
|
Plugins(ctx context.Context) ([]*model.Plugin, error)
|
||||||
FsEntry(ctx context.Context, path string) (fs.FsEntry, error)
|
FsEntry(ctx context.Context, path string) (fs.FsEntry, error)
|
||||||
}
|
}
|
||||||
type ResolverFSResolver interface {
|
|
||||||
Entries(ctx context.Context, obj *fs.ResolverFs) ([]fs.FsEntry, error)
|
|
||||||
}
|
|
||||||
type SimpleDirResolver interface {
|
|
||||||
Entries(ctx context.Context, obj *fs.SimpleDir) ([]fs.FsEntry, error)
|
|
||||||
}
|
|
||||||
type SubscriptionResolver interface {
|
type SubscriptionResolver interface {
|
||||||
TaskProgress(ctx context.Context, taskID string) (<-chan model.Progress, error)
|
TaskProgress(ctx context.Context, taskID string) (<-chan model.Progress, error)
|
||||||
}
|
}
|
||||||
|
@ -131,7 +123,7 @@ func (e *executableSchema) Schema() *ast.Schema {
|
||||||
return parsedSchema
|
return parsedSchema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
|
func (e *executableSchema) Complexity(ctx context.Context, typeName, field string, childComplexity int, rawArgs map[string]any) (int, bool) {
|
||||||
ec := executionContext{nil, e, 0, 0, nil}
|
ec := executionContext{nil, e, 0, 0, nil}
|
||||||
_ = ec
|
_ = ec
|
||||||
switch typeName + "." + field {
|
switch typeName + "." + field {
|
||||||
|
@ -148,7 +140,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
args, err := ec.field_Mutation_uploadFile_args(context.TODO(), rawArgs)
|
args, err := ec.field_Mutation_uploadFile_args(ctx, rawArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
@ -174,7 +166,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
args, err := ec.field_Query_fsEntry_args(context.TODO(), rawArgs)
|
args, err := ec.field_Query_fsEntry_args(ctx, rawArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
@ -249,7 +241,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
args, err := ec.field_Subscription_taskProgress_args(context.TODO(), rawArgs)
|
args, err := ec.field_Subscription_taskProgress_args(ctx, rawArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1230,7 @@ func (ec *executionContext) _ResolverFS_entries(ctx context.Context, field graph
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||||
directive0 := func(rctx context.Context) (any, error) {
|
directive0 := func(rctx context.Context) (any, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.ResolverFS().Entries(rctx, obj)
|
return obj.Entries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
directive1 := func(ctx context.Context) (any, error) {
|
directive1 := func(ctx context.Context) (any, error) {
|
||||||
|
@ -1280,8 +1272,8 @@ func (ec *executionContext) fieldContext_ResolverFS_entries(_ context.Context, f
|
||||||
fc = &graphql.FieldContext{
|
fc = &graphql.FieldContext{
|
||||||
Object: "ResolverFS",
|
Object: "ResolverFS",
|
||||||
Field: field,
|
Field: field,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE")
|
return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE")
|
||||||
},
|
},
|
||||||
|
@ -1424,7 +1416,7 @@ func (ec *executionContext) _SimpleDir_entries(ctx context.Context, field graphq
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) {
|
||||||
directive0 := func(rctx context.Context) (any, error) {
|
directive0 := func(rctx context.Context) (any, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.SimpleDir().Entries(rctx, obj)
|
return obj.Entries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
directive1 := func(ctx context.Context) (any, error) {
|
directive1 := func(ctx context.Context) (any, error) {
|
||||||
|
@ -1466,8 +1458,8 @@ func (ec *executionContext) fieldContext_SimpleDir_entries(_ context.Context, fi
|
||||||
fc = &graphql.FieldContext{
|
fc = &graphql.FieldContext{
|
||||||
Object: "SimpleDir",
|
Object: "SimpleDir",
|
||||||
Field: field,
|
Field: field,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||||
return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE")
|
return nil, errors.New("FieldContext.Child cannot be called on type INTERFACE")
|
||||||
},
|
},
|
||||||
|
@ -4141,44 +4133,13 @@ func (ec *executionContext) _ResolverFS(ctx context.Context, sel ast.SelectionSe
|
||||||
case "name":
|
case "name":
|
||||||
out.Values[i] = ec._ResolverFS_name(ctx, field, obj)
|
out.Values[i] = ec._ResolverFS_name(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&out.Invalids, 1)
|
out.Invalids++
|
||||||
}
|
}
|
||||||
case "entries":
|
case "entries":
|
||||||
field := field
|
out.Values[i] = ec._ResolverFS_entries(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
out.Invalids++
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
res = ec._ResolverFS_entries(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&fs.Invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if field.Deferrable != nil {
|
|
||||||
dfs, ok := deferred[field.Deferrable.Label]
|
|
||||||
di := 0
|
|
||||||
if ok {
|
|
||||||
dfs.AddField(field)
|
|
||||||
di = len(dfs.Values) - 1
|
|
||||||
} else {
|
|
||||||
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
|
|
||||||
deferred[field.Deferrable.Label] = dfs
|
|
||||||
}
|
|
||||||
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
|
|
||||||
return innerFunc(ctx, dfs)
|
|
||||||
})
|
|
||||||
|
|
||||||
// don't run the out.Concurrently() call below
|
|
||||||
out.Values[i] = graphql.Null
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
}
|
}
|
||||||
|
@ -4254,44 +4215,13 @@ func (ec *executionContext) _SimpleDir(ctx context.Context, sel ast.SelectionSet
|
||||||
case "name":
|
case "name":
|
||||||
out.Values[i] = ec._SimpleDir_name(ctx, field, obj)
|
out.Values[i] = ec._SimpleDir_name(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&out.Invalids, 1)
|
out.Invalids++
|
||||||
}
|
}
|
||||||
case "entries":
|
case "entries":
|
||||||
field := field
|
out.Values[i] = ec._SimpleDir_entries(ctx, field, obj)
|
||||||
|
if out.Values[i] == graphql.Null {
|
||||||
innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) {
|
out.Invalids++
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
res = ec._SimpleDir_entries(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&fs.Invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if field.Deferrable != nil {
|
|
||||||
dfs, ok := deferred[field.Deferrable.Label]
|
|
||||||
di := 0
|
|
||||||
if ok {
|
|
||||||
dfs.AddField(field)
|
|
||||||
di = len(dfs.Values) - 1
|
|
||||||
} else {
|
|
||||||
dfs = graphql.NewFieldSet([]graphql.CollectedField{field})
|
|
||||||
deferred[field.Deferrable.Label] = dfs
|
|
||||||
}
|
|
||||||
dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler {
|
|
||||||
return innerFunc(ctx, dfs)
|
|
||||||
})
|
|
||||||
|
|
||||||
// don't run the out.Concurrently() call below
|
|
||||||
out.Values[i] = graphql.Null
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) })
|
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ package resolver
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
graph "git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql"
|
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql/fs"
|
"git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,11 +20,5 @@ func (r *simpleDirResolver) Entries(ctx context.Context, obj *fs.SimpleDir) ([]f
|
||||||
return obj.SimpleDirEntries(ctx)
|
return obj.SimpleDirEntries(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolverFS returns graph.ResolverFSResolver implementation.
|
|
||||||
func (r *Resolver) ResolverFS() graph.ResolverFSResolver { return &resolverFSResolver{r} }
|
|
||||||
|
|
||||||
// SimpleDir returns graph.SimpleDirResolver implementation.
|
|
||||||
func (r *Resolver) SimpleDir() graph.SimpleDirResolver { return &simpleDirResolver{r} }
|
|
||||||
|
|
||||||
type resolverFSResolver struct{ *Resolver }
|
type resolverFSResolver struct{ *Resolver }
|
||||||
type simpleDirResolver struct{ *Resolver }
|
type simpleDirResolver struct{ *Resolver }
|
||||||
|
|
|
@ -2,7 +2,7 @@ package resolver
|
||||||
|
|
||||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||||
// will be copied through when generating and any unknown code will be moved to the end.
|
// will be copied through when generating and any unknown code will be moved to the end.
|
||||||
// Code generated by github.com/99designs/gqlgen version v0.17.70
|
// Code generated by github.com/99designs/gqlgen version v0.17.72
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -2,7 +2,7 @@ package resolver
|
||||||
|
|
||||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||||
// will be copied through when generating and any unknown code will be moved to the end.
|
// will be copied through when generating and any unknown code will be moved to the end.
|
||||||
// Code generated by github.com/99designs/gqlgen version v0.17.70
|
// Code generated by github.com/99designs/gqlgen version v0.17.72
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -2,7 +2,7 @@ package resolver
|
||||||
|
|
||||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||||
// will be copied through when generating and any unknown code will be moved to the end.
|
// will be copied through when generating and any unknown code will be moved to the end.
|
||||||
// Code generated by github.com/99designs/gqlgen version v0.17.70
|
// Code generated by github.com/99designs/gqlgen version v0.17.72
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"git.kmsign.ru/royalcat/tstor/server/pkg/rlog"
|
"git.kmsign.ru/royalcat/tstor/server/pkg/rlog"
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/config"
|
"git.kmsign.ru/royalcat/tstor/server/src/config"
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/daemon"
|
"git.kmsign.ru/royalcat/tstor/server/src/daemon"
|
||||||
|
graph "git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql"
|
||||||
|
"git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql/resolver"
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
|
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
|
||||||
echopprof "github.com/labstack/echo-contrib/pprof"
|
echopprof "github.com/labstack/echo-contrib/pprof"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
@ -26,16 +28,31 @@ func Run(cfg config.WebUi, vfs vfs.Filesystem, daemons []daemon.Daemon) error {
|
||||||
// Logger(),
|
// Logger(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// var qbitdaemon *qbittorrent.Daemon
|
|
||||||
// for _, dm := range daemons {
|
|
||||||
// if dm.Name() == qbittorrent.DaemonName {
|
|
||||||
// qbitdaemon = dm.(*qbittorrent.Daemon)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
echopprof.Register(r)
|
echopprof.Register(r)
|
||||||
|
|
||||||
r.Any("/graphql", echo.WrapHandler((GraphQLHandler(vfs))))
|
for _, dm := range daemons {
|
||||||
|
if dm, ok := dm.(daemon.DaemonWithGraphQL); ok {
|
||||||
|
name := dm.Name()
|
||||||
|
schema := dm.GraphQLSchema()
|
||||||
|
|
||||||
|
r.Any(fmt.Sprintf("/daemon/%s/graphql", name), echo.WrapHandler((graphQLHandler(schema))))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
schema := graph.NewExecutableSchema(
|
||||||
|
graph.Config{
|
||||||
|
Resolvers: &resolver.Resolver{
|
||||||
|
// QBitTorrentDaemon: qbitdaemon,
|
||||||
|
VFS: vfs,
|
||||||
|
},
|
||||||
|
Directives: graph.DirectiveRoot{
|
||||||
|
Resolver: NoopDirective,
|
||||||
|
Stream: NoopDirective,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
r.Any("/graphql", echo.WrapHandler((graphQLHandler(schema))))
|
||||||
r.GET("/metrics", echo.WrapHandler(promhttp.Handler()))
|
r.GET("/metrics", echo.WrapHandler(promhttp.Handler()))
|
||||||
|
|
||||||
log.Info("starting webserver", "host", fmt.Sprintf("%s:%d", cfg.IP, cfg.Port))
|
log.Info("starting webserver", "host", fmt.Sprintf("%s:%d", cfg.IP, cfg.Port))
|
||||||
|
|
|
@ -4,9 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
graph "git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql"
|
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/delivery/graphql/resolver"
|
|
||||||
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
|
|
||||||
"github.com/99designs/gqlgen/graphql"
|
"github.com/99designs/gqlgen/graphql"
|
||||||
"github.com/99designs/gqlgen/graphql/handler"
|
"github.com/99designs/gqlgen/graphql/handler"
|
||||||
"github.com/99designs/gqlgen/graphql/handler/extension"
|
"github.com/99designs/gqlgen/graphql/handler/extension"
|
||||||
|
@ -15,25 +12,12 @@ import (
|
||||||
"github.com/ravilushqa/otelgqlgen"
|
"github.com/ravilushqa/otelgqlgen"
|
||||||
)
|
)
|
||||||
|
|
||||||
func noopDirective(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
|
func NoopDirective(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
|
||||||
return next(ctx)
|
return next(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GraphQLHandler(vfs vfs.Filesystem) http.Handler {
|
func graphQLHandler(schema graphql.ExecutableSchema) http.Handler {
|
||||||
graphqlHandler := handler.NewDefaultServer(
|
graphqlHandler := handler.NewDefaultServer(schema)
|
||||||
graph.NewExecutableSchema(
|
|
||||||
graph.Config{
|
|
||||||
Resolvers: &resolver.Resolver{
|
|
||||||
// QBitTorrentDaemon: qbitdaemon,
|
|
||||||
VFS: vfs,
|
|
||||||
},
|
|
||||||
Directives: graph.DirectiveRoot{
|
|
||||||
Resolver: noopDirective,
|
|
||||||
Stream: noopDirective,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
// log := rlog.Component("graphql")
|
// log := rlog.Component("graphql")
|
||||||
// graphqlHandler.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
|
// graphqlHandler.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue