engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2024 Puter Technologies Inc. * * This file is part of puter-fuse. * * puter-fuse is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	ROOT_UUID = "00000000-0000-0000-0000-000000000000"
)

Variables

This section is empty.

Functions

func NodeInfoToArtificialCloudItem

func NodeInfoToArtificialCloudItem(nodeInfo *NodeInfo) putersdk.CloudItem

Types

type AssociationService

type AssociationService struct {
	LocalUIDToRemoteUID lang.IMap[string, string]
	RemoteUIDToLocalUID lang.IMap[string, string]
	LocalUIDToIno       lang.IMap[string, uint64]
	InoToLocalUID       lang.IMap[uint64, string]

	// LocalUIDToNodeInfo   lang.IMap[string, *fao.NodeInfo]
	LocalUIDToNodeInfo *kvdotgo.KVMap[string, fao.NodeInfo]
	// PathToLocalUID     *kvdotgo.KVMap[string, string]
	PathToLocalUID lang.IMap[string, string]

	LocalUIDToBaseHash lang.IMap[string, string]
	PathToBaseHash     lang.IMap[string, string]

	CacheStampedeMapLock sync.RWMutex
	CacheStampedeMap     map[string]*sync.Mutex
}

func CreateAssociationService

func CreateAssociationService() *AssociationService

func (*AssociationService) GetLocalUIDFromRemote

func (svc *AssociationService) GetLocalUIDFromRemote(remoteUID string) string

func (*AssociationService) Init

func (svc *AssociationService) Init(services services.IServiceContainer)

type BLOBCacheEntry

type BLOBCacheEntry struct {
	Uid                string
	Hash               string
	ReferencesLock     sync.RWMutex
	References         []*BLOBCacheReference
	AwaitRelease       chan struct{}
	AwaitForgotten     chan struct{}
	AwaitRemovedFromFS chan struct{}
}

type BLOBCacheReference

type BLOBCacheReference struct {
	// contains filtered or unexported fields
}

func (*BLOBCacheReference) AwaitForgotten

func (ref *BLOBCacheReference) AwaitForgotten() <-chan struct{}

func (*BLOBCacheReference) AwaitRemovedFromFS

func (ref *BLOBCacheReference) AwaitRemovedFromFS() <-chan struct{}

func (*BLOBCacheReference) GetHash

func (ref *BLOBCacheReference) GetHash() string

func (*BLOBCacheReference) Release

func (ref *BLOBCacheReference) Release()

type BLOBCacheService

type BLOBCacheService struct {
	ConfigService IConfig
	KnownBlobs    lang.IMap[string, *BLOBCacheEntry]
	Filesystem    afero.Fs
}

func CreateBLOBCacheService

func CreateBLOBCacheService(fs afero.Fs) *BLOBCacheService

func (*BLOBCacheService) Get

func (svc *BLOBCacheService) Get(
	hash string, offset, size int64,
) io.Reader

func (*BLOBCacheService) GetBytes

func (svc *BLOBCacheService) GetBytes(
	hash string, offset int64,
	buffer []byte,
) (int, bool, error)

func (*BLOBCacheService) Hold

func (svc *BLOBCacheService) Hold(
	hash string,
) *BLOBCacheReference

func (*BLOBCacheService) Init

func (svc *BLOBCacheService) Init(services services.IServiceContainer)

func (*BLOBCacheService) Store

func (svc *BLOBCacheService) Store(
	reader io.Reader,
) *BLOBCacheReference

type ConfigLoadedEvent

type ConfigLoadedEvent struct{}

type ConfigService

type ConfigService struct {
	IConfig
}

func CreateConfigService

func CreateConfigService() *ConfigService

func (*ConfigService) Init

func (svc *ConfigService) Init(services services.IServiceContainer)

type IConfig

type IConfig interface {
	GetString(key string) string
}

using this interface allows for keeping track of which methods of viper are being used, in case we ever swap it out.

type I_Batcher_EnqueueOperationRequest

type I_Batcher_EnqueueOperationRequest interface {
	EnqueueOperationRequest(
		operation putersdk.Operation,
		blob []byte,
	) OperationRequestPromise
}

type Mutation

type Mutation interface {
	Apply(inStream io.ReadCloser) (outStream io.ReadCloser, err error)
	ApplyToBuffer(buffer []byte, offset int64)
}

type MutationChain

type MutationChain struct {
	Releasables []Releasable
	Mutations   []interface{}
}

func (*MutationChain) ApplyToBuffer

func (chain *MutationChain) ApplyToBuffer(buffer []byte, offset int64)

type MutationReference

type MutationReference struct{}

func (*MutationReference) Release

func (ref *MutationReference) Release()

type NodeInfo

type NodeInfo struct {
	Path string
	Name string
	Type NodeType
	Size uint64
}

type NodeType

type NodeType int
const (
	Dir NodeType = iota
	File
	Symlink
)

type OperationRequest

type OperationRequest struct {
	Operation putersdk.Operation
	Resolve   chan<- OperationResponse
	// contains filtered or unexported fields
}

type OperationRequestPromise

type OperationRequestPromise struct {
	Await <-chan OperationResponse
}

type OperationResponse

type OperationResponse struct {
	Data map[string]interface{}
}

type OperationService

type OperationService struct {
	SDK                   *putersdk.PuterSDK
	OperationRequestQueue chan *OperationRequest
	QueueReadyQueue       chan struct{}
	// contains filtered or unexported fields
}

func (*OperationService) EnqueueOperationRequest

func (svc_op *OperationService) EnqueueOperationRequest(
	operation putersdk.Operation,
	blob []byte,
) OperationRequestPromise

func (*OperationService) Init

func (svc_op *OperationService) Init(services services.IServiceContainer)

type PendingNodeService

type PendingNodeService struct {
	LookupTablePath   map[string]*NodeInfo
	LookupTableParent map[string][]*NodeInfo

	// locks
	LookupTablePathLock   sync.RWMutex
	LookupTableParentLock sync.RWMutex
	// contains filtered or unexported fields
}

func (*PendingNodeService) Forget

func (svc *PendingNodeService) Forget(parent, name string)

func (*PendingNodeService) GetChildren

func (svc *PendingNodeService) GetChildren(parent string) []*NodeInfo

func (*PendingNodeService) GetNodeInfo

func (svc *PendingNodeService) GetNodeInfo(path string) *NodeInfo

func (*PendingNodeService) Init

func (svc *PendingNodeService) Init(services services.IServiceContainer)
func (svc *PendingNodeService) Link(parent, name string, typ NodeType) *NodeInfo

func (*PendingNodeService) SetFileData

func (svc *PendingNodeService) SetFileData(path string, data []byte) int

The caller of this method must aquire a lock

type Releasable

type Releasable interface {
	Release()
}

type RemoveMutation

type RemoveMutation struct{}

type TruncateMutation

type TruncateMutation struct {
	Size uint64
}

type VirtualDirectoryEntry

type VirtualDirectoryEntry struct {
	// Directories lang.IMap[string, string]
	// Files       lang.IMap[string, string]
	VirtualEntry
	MemberUIDToName lang.IMap[string, string]
	MemberNameToUID lang.IMap[string, string]
	LastReaddir     time.Time
}

func CreateVirtualDirectoryEntry

func CreateVirtualDirectoryEntry() *VirtualDirectoryEntry

func (*VirtualDirectoryEntry) GetUIDs

func (v *VirtualDirectoryEntry) GetUIDs() []string

type VirtualEntry

type VirtualEntry struct {
}

type VirtualFileEntry

type VirtualFileEntry struct {
	VirtualEntry
}

func CreateVirtualFileEntry

func CreateVirtualFileEntry() *VirtualFileEntry

type VirtualTreeService

type VirtualTreeService struct {
	DirectoriesCacheLock *lang.CacheStampedeMap[string]
	Directories          lang.IMap[string, *VirtualDirectoryEntry]
	Files                lang.IMap[string, *VirtualFileEntry]
}

func CreateVirtualTreeService

func CreateVirtualTreeService() *VirtualTreeService

func (*VirtualTreeService) Init

func (svc *VirtualTreeService) Init(services services.IServiceContainer)
func (svc *VirtualTreeService) Link(parentUID, childUID, name string)

func (*VirtualTreeService) RegisterDirectory

func (svc *VirtualTreeService) RegisterDirectory(uid string) string

func (*VirtualTreeService) RegisterFile

func (svc *VirtualTreeService) RegisterFile(uid string) string

func (*VirtualTreeService) ResolvePath

func (svc *VirtualTreeService) ResolvePath(parts []string) *VirtualDirectoryEntry
func (svc *VirtualTreeService) Unlink(parentUID, childUID string)

func (*VirtualTreeService) UpdateLastReaddir

func (svc *VirtualTreeService) UpdateLastReaddir(uid string)

type WholeFileCacheService

type WholeFileCacheService struct {
	FileVer  map[string]int
	FileData map[string][]byte
	// contains filtered or unexported fields
}

func (*WholeFileCacheService) DeleteFileData

func (svc_cache *WholeFileCacheService) DeleteFileData(path string, ver int)

func (*WholeFileCacheService) GetFileData

func (svc_cache *WholeFileCacheService) GetFileData(path string) []byte

func (*WholeFileCacheService) Init

func (svc_cache *WholeFileCacheService) Init(services services.IServiceContainer)

func (*WholeFileCacheService) SetFileData

func (svc_cache *WholeFileCacheService) SetFileData(path string, data []byte) int

type WriteCacheService

type WriteCacheService struct {
	CachedOperations lang.IMap[string, *MutationChain]
}

func CreateWriteCacheService

func CreateWriteCacheService() *WriteCacheService

func (*WriteCacheService) ApplyMutation

func (svc *WriteCacheService) ApplyMutation(localUID string, mut Mutation) *MutationReference

func (*WriteCacheService) ApplyToBuffer

func (svc *WriteCacheService) ApplyToBuffer(localUID string, buffer []byte, offset int64)

func (*WriteCacheService) Init

func (svc *WriteCacheService) Init(services services.IServiceContainer)

type WriteMutation

type WriteMutation struct {
	Data   []byte
	Offset int64
}

func (*WriteMutation) Apply

func (mut *WriteMutation) Apply(inStream io.ReadCloser) (outStream io.ReadCloser, err error)

Returns a reader which will emit the contents of inStream, replacing the bytes at 'Offset' with the buffer 'Data'.

func (*WriteMutation) ApplyToBuffer

func (mut *WriteMutation) ApplyToBuffer(buffer []byte, offset int64)

Jump to

Keyboard shortcuts

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