Loading server/console.go +7 −2 Original line number Diff line number Diff line Loading @@ -57,10 +57,15 @@ type ctxConsoleUsernameKey struct{} type ctxConsoleEmailKey struct{} type ctxConsoleRoleKey struct{} type ConsoleStorage struct { db *sql.DB logger *zap.Logger } type ConsoleServer struct { console.UnimplementedConsoleServer ConsoleStorage logger *zap.Logger db *sql.DB config Config tracker Tracker router MessageRouter Loading Loading @@ -100,8 +105,8 @@ func StartConsoleServer(logger *zap.Logger, startupLogger *zap.Logger, db *sql.D ctx, ctxCancelFn := context.WithCancel(context.Background()) s := &ConsoleServer{ ConsoleStorage: ConsoleStorage{db, logger}, logger: logger, db: db, config: config, tracker: tracker, router: router, Loading server/console_storage.go +6 −8 Original line number Diff line number Diff line Loading @@ -42,9 +42,7 @@ type consoleStorageCursor struct { Read int32 } var collectionSetCache = &atomic.Value{} func (s *ConsoleServer) DeleteStorage(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) { func (s *ConsoleStorage) DeleteStorage(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) { _, err := s.db.ExecContext(ctx, "TRUNCATE TABLE storage") if err != nil { s.logger.Error("Failed to truncate Storage table.", zap.Error(err)) Loading @@ -53,7 +51,7 @@ func (s *ConsoleServer) DeleteStorage(ctx context.Context, in *emptypb.Empty) (* return &emptypb.Empty{}, nil } func (s *ConsoleServer) DeleteStorageObject(ctx context.Context, in *console.DeleteStorageObjectRequest) (*emptypb.Empty, error) { func (s *ConsoleStorage) DeleteStorageObject(ctx context.Context, in *console.DeleteStorageObjectRequest) (*emptypb.Empty, error) { if in.Collection == "" { return nil, status.Error(codes.InvalidArgument, "Requires a valid collection.") } Loading Loading @@ -89,7 +87,7 @@ func (s *ConsoleServer) DeleteStorageObject(ctx context.Context, in *console.Del return &emptypb.Empty{}, nil } func (s *ConsoleServer) GetStorage(ctx context.Context, in *api.ReadStorageObjectId) (*api.StorageObject, error) { func (s *ConsoleStorage) GetStorage(ctx context.Context, in *api.ReadStorageObjectId) (*api.StorageObject, error) { if in.Collection == "" { return nil, status.Error(codes.InvalidArgument, "Requires a valid collection.") } Loading @@ -115,7 +113,7 @@ func (s *ConsoleServer) GetStorage(ctx context.Context, in *api.ReadStorageObjec return objects.Objects[0], nil } func (s *ConsoleServer) ListStorageCollections(ctx context.Context, in *emptypb.Empty) (*console.StorageCollectionsList, error) { func (s *ConsoleStorage) ListStorageCollections(ctx context.Context, in *emptypb.Empty) (*console.StorageCollectionsList, error) { collectionSetCache := collectionSetCache.Load() if collectionSetCache == nil { return &console.StorageCollectionsList{ Loading @@ -136,7 +134,7 @@ func (s *ConsoleServer) ListStorageCollections(ctx context.Context, in *emptypb. }, nil } func (s *ConsoleServer) ListStorage(ctx context.Context, in *console.ListStorageRequest) (*console.StorageList, error) { func (s *ConsoleStorage) ListStorage(ctx context.Context, in *console.ListStorageRequest) (*console.StorageList, error) { const defaultLimit = 100 // Validate user ID, if provided. Loading Loading @@ -302,7 +300,7 @@ func (s *ConsoleServer) ListStorage(ctx context.Context, in *console.ListStorage return response, nil } func (s *ConsoleServer) WriteStorageObject(ctx context.Context, in *console.WriteStorageObjectRequest) (*api.StorageObjectAck, error) { func (s *ConsoleStorage) WriteStorageObject(ctx context.Context, in *console.WriteStorageObjectRequest) (*api.StorageObjectAck, error) { if in.Collection == "" { return nil, status.Error(codes.InvalidArgument, "Requires a valid collection.") } Loading Loading
server/console.go +7 −2 Original line number Diff line number Diff line Loading @@ -57,10 +57,15 @@ type ctxConsoleUsernameKey struct{} type ctxConsoleEmailKey struct{} type ctxConsoleRoleKey struct{} type ConsoleStorage struct { db *sql.DB logger *zap.Logger } type ConsoleServer struct { console.UnimplementedConsoleServer ConsoleStorage logger *zap.Logger db *sql.DB config Config tracker Tracker router MessageRouter Loading Loading @@ -100,8 +105,8 @@ func StartConsoleServer(logger *zap.Logger, startupLogger *zap.Logger, db *sql.D ctx, ctxCancelFn := context.WithCancel(context.Background()) s := &ConsoleServer{ ConsoleStorage: ConsoleStorage{db, logger}, logger: logger, db: db, config: config, tracker: tracker, router: router, Loading
server/console_storage.go +6 −8 Original line number Diff line number Diff line Loading @@ -42,9 +42,7 @@ type consoleStorageCursor struct { Read int32 } var collectionSetCache = &atomic.Value{} func (s *ConsoleServer) DeleteStorage(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) { func (s *ConsoleStorage) DeleteStorage(ctx context.Context, in *emptypb.Empty) (*emptypb.Empty, error) { _, err := s.db.ExecContext(ctx, "TRUNCATE TABLE storage") if err != nil { s.logger.Error("Failed to truncate Storage table.", zap.Error(err)) Loading @@ -53,7 +51,7 @@ func (s *ConsoleServer) DeleteStorage(ctx context.Context, in *emptypb.Empty) (* return &emptypb.Empty{}, nil } func (s *ConsoleServer) DeleteStorageObject(ctx context.Context, in *console.DeleteStorageObjectRequest) (*emptypb.Empty, error) { func (s *ConsoleStorage) DeleteStorageObject(ctx context.Context, in *console.DeleteStorageObjectRequest) (*emptypb.Empty, error) { if in.Collection == "" { return nil, status.Error(codes.InvalidArgument, "Requires a valid collection.") } Loading Loading @@ -89,7 +87,7 @@ func (s *ConsoleServer) DeleteStorageObject(ctx context.Context, in *console.Del return &emptypb.Empty{}, nil } func (s *ConsoleServer) GetStorage(ctx context.Context, in *api.ReadStorageObjectId) (*api.StorageObject, error) { func (s *ConsoleStorage) GetStorage(ctx context.Context, in *api.ReadStorageObjectId) (*api.StorageObject, error) { if in.Collection == "" { return nil, status.Error(codes.InvalidArgument, "Requires a valid collection.") } Loading @@ -115,7 +113,7 @@ func (s *ConsoleServer) GetStorage(ctx context.Context, in *api.ReadStorageObjec return objects.Objects[0], nil } func (s *ConsoleServer) ListStorageCollections(ctx context.Context, in *emptypb.Empty) (*console.StorageCollectionsList, error) { func (s *ConsoleStorage) ListStorageCollections(ctx context.Context, in *emptypb.Empty) (*console.StorageCollectionsList, error) { collectionSetCache := collectionSetCache.Load() if collectionSetCache == nil { return &console.StorageCollectionsList{ Loading @@ -136,7 +134,7 @@ func (s *ConsoleServer) ListStorageCollections(ctx context.Context, in *emptypb. }, nil } func (s *ConsoleServer) ListStorage(ctx context.Context, in *console.ListStorageRequest) (*console.StorageList, error) { func (s *ConsoleStorage) ListStorage(ctx context.Context, in *console.ListStorageRequest) (*console.StorageList, error) { const defaultLimit = 100 // Validate user ID, if provided. Loading Loading @@ -302,7 +300,7 @@ func (s *ConsoleServer) ListStorage(ctx context.Context, in *console.ListStorage return response, nil } func (s *ConsoleServer) WriteStorageObject(ctx context.Context, in *console.WriteStorageObjectRequest) (*api.StorageObjectAck, error) { func (s *ConsoleStorage) WriteStorageObject(ctx context.Context, in *console.WriteStorageObjectRequest) (*api.StorageObjectAck, error) { if in.Collection == "" { return nil, status.Error(codes.InvalidArgument, "Requires a valid collection.") } Loading