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

Remove dead-code #2157

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9014e03
remove internal/datasets/subjectsetbytype.go:93:28: unreachable func:…
Dec 5, 2024
0e1f6bc
remove internal/datastore/crdb/options.go:329:6: unreachable func: De…
IvanCherepov Dec 5, 2024
0ceb39e
remove internal/datastore/mysql/options.go:218:6: unreachable func: D…
IvanCherepov Dec 5, 2024
c005116
remove internal/datastore/postgres/log_tracer.go:13:25: unreachable f…
IvanCherepov Dec 5, 2024
7bb1f2b
internal/datastore/postgres/options.go:341:6: unreachable func: Debug…
IvanCherepov Dec 5, 2024
feb1a98
remove internal/datastore/postgres/options.go:348:6: unreachable func…
IvanCherepov Dec 5, 2024
8b2f9f3
remove internal/datastore/postgres/common/pgx.go:166:6: unreachable f…
IvanCherepov Dec 5, 2024
94d707b
remove internal/dispatch/combined/combined.go:129:6: unreachable func…
IvanCherepov Dec 5, 2024
6780f19
remove internal/graph/errors.go:59:6: unreachable func: NewAlwaysFailErr
IvanCherepov Dec 5, 2024
fed7efb
remove internal/graph/errors.go:73:34: unreachable func: RelationNotF…
IvanCherepov Dec 5, 2024
45e8077
remove internal/graph/errors.go:78:34: unreachable func: RelationNotF…
IvanCherepov Dec 5, 2024
da1f8fb
internal/graph/errors.go:82:34: unreachable func: RelationNotFoundErr…
IvanCherepov Dec 5, 2024
5587d0c
remove internal/graph/errors.go:87:34: unreachable func: RelationNotF…
IvanCherepov Dec 5, 2024
a5d0186
remove internal/graph/errors.go:95:6: unreachable func: NewRelationNo…
IvanCherepov Dec 5, 2024
23e7022
remove internal/graph/errors.go:95:6: unreachable func: NewRelationNo…
IvanCherepov Dec 5, 2024
796a6f2
remove internal/graph/errors.go:179:6: unreachable func: NewUnimpleme…
IvanCherepov Dec 5, 2024
31c70a5
remove nternal/graph/graph.go:30:24: unreachable func: ExpandResult.R…
IvanCherepov Dec 5, 2024
def7020
remove internal/graph/graph.go:38:6: unreachable func: AlwaysFailExpand
IvanCherepov Dec 5, 2024
fe86faa
remove internal/logging/logger.go:39:6: unreachable func: Log
IvanCherepov Dec 5, 2024
2cafd77
remove internal/logging/logger.go:43:6: unreachable func: Print an in…
IvanCherepov Dec 5, 2024
ff9785d
remove internal/middleware/dispatcher/dispatcher.go:28:6: unreachable…
IvanCherepov Dec 5, 2024
13c5af5
remove internal/services/shared/errors.go:109:6: unreachable func: As…
IvanCherepov Dec 5, 2024
441cda7
remove internal/services/shared/interceptor.go:16:50: unreachable fun…
IvanCherepov Dec 5, 2024
68de005
remove internal/services/v0/developer.go:26:6: unreachable func: Regi…
IvanCherepov Dec 5, 2024
9830df7
remove internal/testfixtures/generator.go:18:6: unreachable func: Ran…
IvanCherepov Dec 5, 2024
4631324
fix /Users/ivan/Documents/GitHub/spicedb/internal/graph/errors.go:64:…
IvanCherepov Dec 5, 2024
c644e31
fix /Users/ivan/Documents/GitHub/spicedb/internal/graph/errors.go:69:…
IvanCherepov Dec 5, 2024
4a53dbf
fix /Users/ivan/Documents/GitHub/spicedb/internal/services/shared/int…
IvanCherepov Dec 5, 2024
d88f135
fix /Users/ivan/Documents/GitHub/spicedb/pkg/middleware/dispatcher/di…
IvanCherepov Dec 5, 2024
e8991fe
fix /Users/ivan/Documents/GitHub/spicedb/pkg/schemautil/schemautil.go…
IvanCherepov Dec 5, 2024
75be0b1
remove internal/developmentmembership/trackingsubjectset.go:59:32: un…
IvanCherepov Dec 5, 2024
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
5 changes: 0 additions & 5 deletions internal/datasets/subjectsetbytype.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ func (s *SubjectByTypeSet) IsEmpty() bool {
return len(s.byType) == 0
}

// Len returns the number of keys in the set.
func (s *SubjectByTypeSet) Len() int {
return len(s.byType)
}

// SubjectSetForType returns the subject set associated with the given subject type, if any.
func (s *SubjectByTypeSet) SubjectSetForType(rr *core.RelationReference) (SubjectSet, bool) {
found, ok := s.byType[tuple.JoinRelRef(rr.Namespace, rr.Relation)]
Expand Down
9 changes: 0 additions & 9 deletions internal/datastore/crdb/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,6 @@ func WithEnableConnectionBalancing(connectionBalancing bool) Option {
return func(po *crdbOptions) { po.enableConnectionBalancing = connectionBalancing }
}

// DebugAnalyzeBeforeStatistics signals to the Statistics method that it should
// run Analyze on the database before returning statistics. This should only be
// used for debug and testing.
//
// Disabled by default.
func DebugAnalyzeBeforeStatistics() Option {
return func(po *crdbOptions) { po.analyzeBeforeStatistics = true }
}

// FilterMaximumIDCount is the maximum number of IDs that can be used to filter IDs in queries
func FilterMaximumIDCount(filterMaximumIDCount uint16) Option {
return func(po *crdbOptions) { po.filterMaximumIDCount = filterMaximumIDCount }
Expand Down
11 changes: 0 additions & 11 deletions internal/datastore/mysql/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,6 @@ func MaxOpenConns(conns int) Option {
}
}

// DebugAnalyzeBeforeStatistics signals to the Statistics method that it should
// run Analyze Table on the relationships table before returning statistics.
// This should only be used for debug and testing.
//
// Disabled by default.
func DebugAnalyzeBeforeStatistics() Option {
return func(mo *mysqlOptions) {
mo.analyzeBeforeStats = true
}
}

// OverrideLockWaitTimeout sets the lock wait timeout on each new connection established
// with the databases. As an OLTP service, the default of 50s is unbearably long to block
// a write for our service, so we suggest setting this value to the minimum of 1 second.
Expand Down
10 changes: 0 additions & 10 deletions internal/datastore/postgres/common/pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,6 @@ func ParseConfigWithInstrumentation(url string) (*pgx.ConnConfig, error) {
return connConfig, nil
}

// ConnectWithInstrumentation returns a pgx.Conn that has been instrumented for observability
func ConnectWithInstrumentation(ctx context.Context, url string) (*pgx.Conn, error) {
connConfig, err := ParseConfigWithInstrumentation(url)
if err != nil {
return nil, err
}

return pgx.ConnectConfig(ctx, connConfig)
}

// ConnectWithInstrumentationAndTimeout returns a pgx.Conn that has been instrumented for observability
func ConnectWithInstrumentationAndTimeout(ctx context.Context, url string, connectTimeout time.Duration) (*pgx.Conn, error) {
connConfig, err := ParseConfigWithInstrumentation(url)
Expand Down
13 changes: 0 additions & 13 deletions internal/datastore/postgres/log_tracer.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
package postgres

import (
"context"

"github.com/jackc/pgx/v5/tracelog"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

type tracingLogger struct{}

func (tl tracingLogger) Log(ctx context.Context, level tracelog.LogLevel, msg string, _ map[string]interface{}) {
span := trace.SpanFromContext(ctx)
span.AddEvent(msg, trace.WithAttributes(attribute.Stringer("level", level), attribute.String("datastore", "postgres")))
}
18 changes: 0 additions & 18 deletions internal/datastore/postgres/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,24 +333,6 @@ func GCEnabled(isGCEnabled bool) Option {
return func(po *postgresOptions) { po.gcEnabled = isGCEnabled }
}

// DebugAnalyzeBeforeStatistics signals to the Statistics method that it should
// run Analyze on the database before returning statistics. This should only be
// used for debug and testing.
//
// Disabled by default.
func DebugAnalyzeBeforeStatistics() Option {
return func(po *postgresOptions) { po.analyzeBeforeStatistics = true }
}

// WithQueryInterceptor adds an interceptor to all underlying postgres queries
//
// By default, no query interceptor is used.
func WithQueryInterceptor(interceptor pgxcommon.QueryInterceptor) Option {
return func(po *postgresOptions) {
po.queryInterceptor = interceptor
}
}

// MigrationPhase configures the postgres driver to the proper state of a
// multi-phase migration.
//
Expand Down
7 changes: 0 additions & 7 deletions internal/developmentmembership/trackingsubjectset.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ func (tss *TrackingSubjectSet) MustAddFrom(otherSet *TrackingSubjectSet) {
}
}

// RemoveFrom removes any subjects found in the other set from this set.
func (tss *TrackingSubjectSet) RemoveFrom(otherSet *TrackingSubjectSet) {
for key, oss := range otherSet.setByType {
tss.getSetForKey(key).SubtractAll(oss)
}
}

// MustAdd adds the given subjects to this set.
func (tss *TrackingSubjectSet) MustAdd(subjectsAndResources ...FoundSubject) {
err := tss.Add(subjectsAndResources...)
Expand Down
8 changes: 0 additions & 8 deletions internal/dispatch/combined/combined.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,6 @@ func DispatchChunkSize(dispatchChunkSize uint16) Option {
}
}

// RemoteDispatchTimeout sets the maximum timeout for a remote dispatch.
// Defaults to 60s (as defined in the remote dispatcher).
func RemoteDispatchTimeout(remoteDispatchTimeout time.Duration) Option {
return func(state *optionState) {
state.remoteDispatchTimeout = remoteDispatchTimeout
}
}

// NewDispatcher initializes a Dispatcher that caches and redispatches
// optionally to the provided upstream.
func NewDispatcher(options ...Option) (dispatch.Dispatcher, error) {
Expand Down
45 changes: 0 additions & 45 deletions internal/graph/errors.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package graph

import (
"errors"
"fmt"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -55,13 +54,6 @@ type AlwaysFailError struct {
error
}

// NewAlwaysFailErr constructs a new always fail error.
func NewAlwaysFailErr() error {
return AlwaysFailError{
error: errors.New("always fail"),
}
}

// RelationNotFoundError occurs when a relation was not found under a namespace.
type RelationNotFoundError struct {
error
Expand All @@ -79,27 +71,6 @@ func (err RelationNotFoundError) NotFoundRelationName() string {
return err.relationName
}

func (err RelationNotFoundError) MarshalZerologObject(e *zerolog.Event) {
e.Err(err.error).Str("namespace", err.namespaceName).Str("relation", err.relationName)
}

// DetailsMetadata returns the metadata for details for this error.
func (err RelationNotFoundError) DetailsMetadata() map[string]string {
return map[string]string{
"definition_name": err.namespaceName,
"relation_or_permission_name": err.relationName,
}
}

// NewRelationNotFoundErr constructs a new relation not found error.
func NewRelationNotFoundErr(nsName string, relationName string) error {
return RelationNotFoundError{
error: fmt.Errorf("relation/permission `%s` not found under definition `%s`", relationName, nsName),
namespaceName: nsName,
relationName: relationName,
}
}

var _ sharederrors.UnknownRelationError = RelationNotFoundError{}

// RelationMissingTypeInfoError defines an error for when type information is missing from a relation
Expand Down Expand Up @@ -132,15 +103,6 @@ func (err RelationMissingTypeInfoError) DetailsMetadata() map[string]string {
}
}

// NewRelationMissingTypeInfoErr constructs a new relation not missing type information error.
func NewRelationMissingTypeInfoErr(nsName string, relationName string) error {
return RelationMissingTypeInfoError{
error: fmt.Errorf("relation/permission `%s` under definition `%s` is missing type information", relationName, nsName),
namespaceName: nsName,
relationName: relationName,
}
}

// WildcardNotAllowedError occurs when a request sent has an invalid wildcard argument.
type WildcardNotAllowedError struct {
error
Expand Down Expand Up @@ -175,13 +137,6 @@ type UnimplementedError struct {
error
}

// NewUnimplementedErr constructs a new unimplemented error.
func NewUnimplementedErr(baseErr error) error {
return UnimplementedError{
error: baseErr,
}
}

func (e UnimplementedError) Unwrap() error {
return e.error
}
Expand Down
9 changes: 0 additions & 9 deletions internal/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@ type ExpandResult struct {
Err error
}

func (er ExpandResult) ResultError() error {
return er.Err
}

// ReduceableExpandFunc is a function that can be bound to a execution context.
type ReduceableExpandFunc func(ctx context.Context, resultChan chan<- ExpandResult)

// AlwaysFailExpand is a ReduceableExpandFunc which will always fail when reduced.
func AlwaysFailExpand(_ context.Context, resultChan chan<- ExpandResult) {
resultChan <- expandResultError(NewAlwaysFailErr(), emptyMetadata)
}

// ExpandReducer is a type for the functions Any and All which combine check results.
type ExpandReducer func(
ctx context.Context,
Expand Down
11 changes: 0 additions & 11 deletions internal/logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package logging

import (
"context"
"fmt"

"github.com/rs/zerolog"
)
Expand Down Expand Up @@ -36,14 +35,4 @@ func Fatal() *zerolog.Event { return Logger.Fatal() }

func WithLevel(level zerolog.Level) *zerolog.Event { return Logger.WithLevel(level) }

func Log() *zerolog.Event { return Logger.Log() }

func Ctx(ctx context.Context) *zerolog.Logger { return zerolog.Ctx(ctx) }

func Print(v ...interface{}) {
Logger.Debug().CallerSkipFrame(1).Msg(fmt.Sprint(v...))
}

func Printf(format string, v ...interface{}) {
Logger.Debug().CallerSkipFrame(1).Msgf(format, v...)
}
11 changes: 0 additions & 11 deletions internal/middleware/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ func FromContext(ctx context.Context) dispatch.Dispatcher {
return nil
}

// MustFromContext reads the selected dispatcher out of a context.Context, computes a zedtoken
// from it, and panics if it has not been set on the context.
func MustFromContext(ctx context.Context) dispatch.Dispatcher {
dispatcher := FromContext(ctx)
if dispatcher == nil {
panic("dispatcher middleware did not inject dispatcher")
}

return dispatcher
}

// SetInContext adds a dispatcher to the given context
func SetInContext(ctx context.Context, dispatcher dispatch.Dispatcher) error {
handle := ctx.Value(dispatcherKey)
Expand Down
8 changes: 0 additions & 8 deletions internal/services/v0/developer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

v0 "github.com/authzed/authzed-go/proto/authzed/api/v0"
"github.com/authzed/grpcutil"
"google.golang.org/grpc"
"google.golang.org/protobuf/encoding/prototext"

log "github.com/authzed/spicedb/internal/logging"
Expand All @@ -21,13 +20,6 @@ type devServer struct {
shareStore ShareStore
}

// RegisterDeveloperServer adds the Developer Server to a grpc service registrar
// This is preferred over manually registering the service; it will add required middleware
func RegisterDeveloperServer(r grpc.ServiceRegistrar, s v0.DeveloperServiceServer) *grpc.ServiceDesc {
r.RegisterService(grpcutil.WrapMethods(v0.DeveloperService_ServiceDesc, grpcutil.DefaultUnaryMiddleware...), s)
return &v0.DeveloperService_ServiceDesc
}

// NewDeveloperServer creates an instance of the developer server.
func NewDeveloperServer(store ShareStore) v0.DeveloperServiceServer {
return &devServer{
Expand Down
16 changes: 0 additions & 16 deletions internal/testfixtures/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package testfixtures

import (
"context"
"math/rand"
"strconv"
"testing"

Expand All @@ -15,21 +14,6 @@ const (
SubsequentLetters = FirstLetters + "/_|-"
)

func RandomObjectID(length uint8) string {
b := make([]byte, length)
for i := range b {
sourceLetters := SubsequentLetters
if i == 0 {
sourceLetters = FirstLetters
}
// nolint:gosec
// G404 use of non cryptographically secure random number generator is not a security concern here,
// as this is only used for generating fixtures in testing.
b[i] = sourceLetters[rand.Intn(len(sourceLetters))]
}
return string(b)
}

func NewBulkRelationshipGenerator(objectType, relation, subjectType string, count int, t *testing.T) *BulkRelationshipGenerator {
return &BulkRelationshipGenerator{
count,
Expand Down
Loading