sourcegraph/internal/codeintel/uploads/service.go

94 lines
3.1 KiB
Go

package uploads
import (
"context"
"io"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/internal/store"
"github.com/sourcegraph/sourcegraph/internal/codeintel/uploads/shared"
"github.com/sourcegraph/sourcegraph/internal/observation"
"github.com/sourcegraph/sourcegraph/lib/errors"
)
type Service struct {
uploadsStore Store
operations *operations
}
func newService(uploadsStore Store, observationContext *observation.Context) *Service {
return &Service{
uploadsStore: uploadsStore,
operations: newOperations(observationContext),
}
}
type Upload = shared.Upload
type ListOpts struct {
Limit int
}
func (s *Service) List(ctx context.Context, opts ListOpts) (uploads []Upload, err error) {
ctx, endObservation := s.operations.list.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
return s.uploadsStore.List(ctx, store.ListOpts(opts))
}
func (s *Service) Get(ctx context.Context, id int) (upload Upload, ok bool, err error) {
ctx, endObservation := s.operations.get.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
// To be implemented in https://github.com/sourcegraph/sourcegraph/issues/33375
_ = ctx
return Upload{}, false, errors.Newf("unimplemented: uploads.Get")
}
func (s *Service) GetBatch(ctx context.Context, ids ...int) (uploads []Upload, err error) {
ctx, endObservation := s.operations.getBatch.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
// To be implemented in https://github.com/sourcegraph/sourcegraph/issues/33375
_ = ctx
return nil, errors.Newf("unimplemented: uploads.GetBatch")
}
type UploadState struct {
}
func (s *Service) Enqueue(ctx context.Context, state UploadState, reader io.Reader) (err error) {
ctx, endObservation := s.operations.enqueue.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
// To be implemented in https://github.com/sourcegraph/sourcegraph/issues/33375
_ = ctx
return errors.Newf("unimplemented: uploads.Enqueue")
}
func (s *Service) Delete(ctx context.Context, id int) (err error) {
ctx, endObservation := s.operations.delete.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
// To be implemented in https://github.com/sourcegraph/sourcegraph/issues/33375
_ = ctx
return errors.Newf("unimplemented: uploads.Delete")
}
func (s *Service) CommitsVisibleToUpload(ctx context.Context, id int) (commits []string, err error) {
ctx, endObservation := s.operations.commitsVisibleTo.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
// To be implemented in https://github.com/sourcegraph/sourcegraph/issues/33375
_ = ctx
return nil, errors.Newf("unimplemented: uploads.CommitsVisibleToUpload")
}
func (s *Service) UploadsVisibleToCommit(ctx context.Context, commit string) (uploads []Upload, err error) {
ctx, endObservation := s.operations.uploadsVisibleTo.With(ctx, &err, observation.Args{})
defer endObservation(1, observation.Args{})
// To be implemented in https://github.com/sourcegraph/sourcegraph/issues/33375
_ = ctx
return nil, errors.Newf("unimplemented: uploads.UploadsVisibleToCommit")
}