fs

package
v0.7.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fs provides a filesystem-based implementation of the UsersService. It stores user data as JSON files on the local filesystem, making it ideal for development, testing, and single-instance deployments.

Storage Layout

Users are stored in the following directory structure:

{storageDir}/
  {userId}/
    user.json    # User profile data

Thread Safety

The service includes optional in-memory caching via BaseUsersService. File operations are atomic via the goutils/storage package.

Usage

userService := fs.NewUsersService("/path/to/users")
resp, err := userService.CreateUser(ctx, &v1.CreateUserRequest{
    User: &v1.User{Name: "John Doe", Email: "john@example.com"},
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UsersService

type UsersService struct {
	services.BaseUsersService
	// contains filtered or unexported fields
}

UsersService implements services.UsersService using filesystem storage. It embeds BaseUsersService to inherit caching and shared operations.

func NewUsersService

func NewUsersService(storageDir string) *UsersService

NewUsersService creates a new filesystem-backed UsersService

func (*UsersService) CreateUser

CreateUser creates a new user profile

func (*UsersService) DeleteFromStorage

func (s *UsersService) DeleteFromStorage(ctx context.Context, id string) error

DeleteFromStorage implements UserStorageProvider

func (*UsersService) ListAllUsers

func (s *UsersService) ListAllUsers(ctx context.Context) ([]*v1.User, error)

ListAllUsers implements UserStorageProvider

func (*UsersService) LoadUser

func (s *UsersService) LoadUser(ctx context.Context, id string) (*v1.User, error)

LoadUser implements UserStorageProvider

func (*UsersService) SaveUser

func (s *UsersService) SaveUser(ctx context.Context, id string, user *v1.User) error

SaveUser implements UserStorageProvider

func (*UsersService) UpdateUser

UpdateUser updates an existing user profile

func (*UsersService) UserExists

func (s *UsersService) UserExists(ctx context.Context, id string) bool

UserExists implements UserStorageProvider

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL