Migrate thumbnails proto files and adjust related import paths
This commit is contained in:
@@ -3,13 +3,13 @@ package svc
|
||||
import (
|
||||
"context"
|
||||
|
||||
thumbnailssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/thumbnails/v1"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/metrics"
|
||||
v0proto "github.com/owncloud/ocis/thumbnails/pkg/proto/v0"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// NewInstrument returns a service that instruments metrics.
|
||||
func NewInstrument(next v0proto.ThumbnailServiceHandler, metrics *metrics.Metrics) v0proto.ThumbnailServiceHandler {
|
||||
func NewInstrument(next thumbnailssvc.ThumbnailServiceHandler, metrics *metrics.Metrics) thumbnailssvc.ThumbnailServiceHandler {
|
||||
return instrument{
|
||||
next: next,
|
||||
metrics: metrics,
|
||||
@@ -17,12 +17,12 @@ func NewInstrument(next v0proto.ThumbnailServiceHandler, metrics *metrics.Metric
|
||||
}
|
||||
|
||||
type instrument struct {
|
||||
next v0proto.ThumbnailServiceHandler
|
||||
next thumbnailssvc.ThumbnailServiceHandler
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
// GetThumbnail implements the ThumbnailServiceHandler interface.
|
||||
func (i instrument) GetThumbnail(ctx context.Context, req *v0proto.GetThumbnailRequest, rsp *v0proto.GetThumbnailResponse) error {
|
||||
func (i instrument) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, rsp *thumbnailssvc.GetThumbnailResponse) error {
|
||||
timer := prometheus.NewTimer(prometheus.ObserverFunc(func(v float64) {
|
||||
us := v * 1000_000
|
||||
i.metrics.Latency.WithLabelValues().Observe(us)
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
v0proto "github.com/owncloud/ocis/thumbnails/pkg/proto/v0"
|
||||
thumbnailssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/thumbnails/v1"
|
||||
)
|
||||
|
||||
// NewLogging returns a service that logs messages.
|
||||
func NewLogging(next v0proto.ThumbnailServiceHandler, logger log.Logger) v0proto.ThumbnailServiceHandler {
|
||||
func NewLogging(next thumbnailssvc.ThumbnailServiceHandler, logger log.Logger) thumbnailssvc.ThumbnailServiceHandler {
|
||||
return logging{
|
||||
next: next,
|
||||
logger: logger,
|
||||
@@ -17,12 +17,12 @@ func NewLogging(next v0proto.ThumbnailServiceHandler, logger log.Logger) v0proto
|
||||
}
|
||||
|
||||
type logging struct {
|
||||
next v0proto.ThumbnailServiceHandler
|
||||
next thumbnailssvc.ThumbnailServiceHandler
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
// GetThumbnail implements the ThumbnailServiceHandler interface.
|
||||
func (l logging) GetThumbnail(ctx context.Context, req *v0proto.GetThumbnailRequest, rsp *v0proto.GetThumbnailResponse) error {
|
||||
func (l logging) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, rsp *thumbnailssvc.GetThumbnailResponse) error {
|
||||
start := time.Now()
|
||||
err := l.next.GetThumbnail(ctx, req, rsp)
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
revactx "github.com/cs3org/reva/pkg/ctx"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
thumbnailssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/thumbnails/v1"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/preprocessor"
|
||||
v0proto "github.com/owncloud/ocis/thumbnails/pkg/proto/v0"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/thumbnail"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/thumbnail/imgsource"
|
||||
"github.com/pkg/errors"
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// NewService returns a service implementation for Service.
|
||||
func NewService(opts ...Option) v0proto.ThumbnailServiceHandler {
|
||||
func NewService(opts ...Option) thumbnailssvc.ThumbnailServiceHandler {
|
||||
options := newOptions(opts...)
|
||||
logger := options.Logger
|
||||
resolutions, err := thumbnail.ParseResolutions(options.Config.Thumbnail.Resolutions)
|
||||
@@ -64,8 +64,8 @@ type PreprocessorOpts struct {
|
||||
}
|
||||
|
||||
// GetThumbnail retrieves a thumbnail for an image
|
||||
func (g Thumbnail) GetThumbnail(ctx context.Context, req *v0proto.GetThumbnailRequest, rsp *v0proto.GetThumbnailResponse) error {
|
||||
_, ok := v0proto.GetThumbnailRequest_ThumbnailType_value[req.ThumbnailType.String()]
|
||||
func (g Thumbnail) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, rsp *thumbnailssvc.GetThumbnailResponse) error {
|
||||
_, ok := thumbnailssvc.GetThumbnailRequest_ThumbnailType_value[req.ThumbnailType.String()]
|
||||
if !ok {
|
||||
g.logger.Debug().Str("thumbnail_type", req.ThumbnailType.String()).Msg("unsupported thumbnail type")
|
||||
return nil
|
||||
@@ -96,7 +96,7 @@ func (g Thumbnail) GetThumbnail(ctx context.Context, req *v0proto.GetThumbnailRe
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g Thumbnail) handleCS3Source(ctx context.Context, req *v0proto.GetThumbnailRequest, encoder thumbnail.Encoder) ([]byte, error) {
|
||||
func (g Thumbnail) handleCS3Source(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, encoder thumbnail.Encoder) ([]byte, error) {
|
||||
src := req.GetCs3Source()
|
||||
sRes, err := g.stat(src.Path, src.Authorization)
|
||||
if err != nil {
|
||||
@@ -135,7 +135,7 @@ func (g Thumbnail) handleCS3Source(ctx context.Context, req *v0proto.GetThumbnai
|
||||
return thumb, nil
|
||||
}
|
||||
|
||||
func (g Thumbnail) handleWebdavSource(ctx context.Context, req *v0proto.GetThumbnailRequest, encoder thumbnail.Encoder) ([]byte, error) {
|
||||
func (g Thumbnail) handleWebdavSource(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, encoder thumbnail.Encoder) ([]byte, error) {
|
||||
src := req.GetWebdavSource()
|
||||
imgURL, err := url.Parse(src.Url)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,24 +5,24 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
v0proto "github.com/owncloud/ocis/thumbnails/pkg/proto/v0"
|
||||
thumbnailssvc "github.com/owncloud/ocis/protogen/gen/ocis/services/thumbnails/v1"
|
||||
thumbnailsTracing "github.com/owncloud/ocis/thumbnails/pkg/tracing"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// NewTracing returns a service that instruments traces.
|
||||
func NewTracing(next v0proto.ThumbnailServiceHandler) v0proto.ThumbnailServiceHandler {
|
||||
func NewTracing(next thumbnailssvc.ThumbnailServiceHandler) thumbnailssvc.ThumbnailServiceHandler {
|
||||
return tracing{
|
||||
next: next,
|
||||
}
|
||||
}
|
||||
|
||||
type tracing struct {
|
||||
next v0proto.ThumbnailServiceHandler
|
||||
next thumbnailssvc.ThumbnailServiceHandler
|
||||
}
|
||||
|
||||
// GetThumbnail implements the ThumbnailServiceHandler interface.
|
||||
func (t tracing) GetThumbnail(ctx context.Context, req *v0proto.GetThumbnailRequest, rsp *v0proto.GetThumbnailResponse) error {
|
||||
func (t tracing) GetThumbnail(ctx context.Context, req *thumbnailssvc.GetThumbnailRequest, rsp *thumbnailssvc.GetThumbnailResponse) error {
|
||||
var span trace.Span
|
||||
|
||||
if thumbnailsTracing.TraceProvider != nil {
|
||||
|
||||
Reference in New Issue
Block a user