model

package
v0.5.16 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: Apache-2.0, MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCIDEntry = errors.New("invalid CID entry in the database")
View Source
var ErrInvalidHTTPConfigEntry = errors.New("invalid ClientConfig entry in the database")
View Source
var ErrInvalidJobState = errors.New("invalid job state")
View Source
var ErrInvalidStringMapEntry = errors.New("invalid string map entry in the database")
View Source
var ErrInvalidStringSliceEntry = errors.New("invalid string slice entry in the database")
View Source
var JobTypeStrings = []string{
	string(Scan),
	string(Pack),
	string(DagGen),
}
View Source
var JobTypes = []JobType{
	Scan,
	Pack,
	DagGen,
}
View Source
var Tables = []any{
	&Worker{},
	&Global{},
	&Preparation{},
	&Storage{},
	&OutputAttachment{},
	&SourceAttachment{},
	&Job{},
	&File{},
	&FileRange{},
	&Directory{},
	&Car{},
	&CarBlock{},
	&Deal{},
	&Schedule{},
	&Wallet{},
}

Functions

func AutoMigrate

func AutoMigrate(db *gorm.DB) error

AutoMigrate attempts to automatically migrate the database schema.

This function performs a few operations:

  1. Automatically migrates the tables in the database to match the structures defined in the application.
  2. Creates an instance ID if it doesn't already exist.
  3. Generates a new encryption salt and stores it in the database if it doesn't already exist.

The purpose of the auto-migration feature is to simplify schema changes and manage basic system configurations without manually altering the database. This is especially useful during development or when deploying updates that include schema changes.

Parameters:

  • db: A pointer to a gorm.DB object, which provides database access.

Returns:

  • An error if any issues arise during the process, otherwise nil.

func DropAll

func DropAll(db *gorm.DB) error

DropAll removes all tables specified in the Tables slice from the database.

This function is typically used during development or testing where a clean database slate is required. It iterates over the predefined Tables list and drops each table. Care should be taken when using this function in production environments as it will result in data loss.

Parameters:

  • db: A pointer to a gorm.DB object, which provides database access.

Returns:

  • An error if any issues arise during the table drop process, otherwise nil.

func IsSecretConfigName added in v0.5.1

func IsSecretConfigName(key string) bool

func StoragePricePerEpochToPricePerDeal

func StoragePricePerEpochToPricePerDeal(price string, dealSize int64, durationEpoch int32) float64

Types

type CID

type CID cid.Cid

func (CID) MarshalBinary added in v0.2.14

func (c CID) MarshalBinary() ([]byte, error)

func (CID) MarshalJSON

func (c CID) MarshalJSON() ([]byte, error)

func (*CID) Scan

func (c *CID) Scan(src any) error

func (CID) String

func (c CID) String() string

func (*CID) UnmarshalBinary added in v0.2.14

func (c *CID) UnmarshalBinary(b []byte) error

func (*CID) UnmarshalJSON

func (c *CID) UnmarshalJSON(b []byte) error

func (CID) Value

func (c CID) Value() (driver.Value, error)

type Car

type Car struct {
	ID          CarID      `` /* 143-byte string literal not displayed */
	CreatedAt   time.Time  `` /* 127-byte string literal not displayed */
	PieceCID    CID        `` /* 148-byte string literal not displayed */
	PieceSize   int64      `cbor:"2,keyasint,omitempty" json:"pieceSize"`
	RootCID     CID        `` /* 148-byte string literal not displayed */
	FileSize    int64      `cbor:"4,keyasint,omitempty" json:"fileSize"`
	StorageID   *StorageID `cbor:"-"                    json:"storageId"                                         table:"verbose"`
	Storage     *Storage   ``                                               /* 163-byte string literal not displayed */
	StoragePath string     `cbor:"-"                    json:"storagePath"` // StoragePath is the path to the CAR file inside the storage. If the StorageID is nil but StoragePath is not empty, it means the CAR file is stored at the local absolute path.
	NumOfFiles  int64      `cbor:"-"                    json:"numOfFiles"                                        table:"verbose"`

	// Association
	PreparationID PreparationID       `cbor:"-" json:"preparationId"                                        table:"-"`
	Preparation   *Preparation        `` /* 128-byte string literal not displayed */
	AttachmentID  *SourceAttachmentID `cbor:"-" json:"attachmentId"                                         table:"-"`
	Attachment    *SourceAttachment   `` /* 128-byte string literal not displayed */
	JobID         *JobID              `cbor:"-" json:"jobId,omitempty"                                      table:"-"`
	Job           *Job                `` /* 128-byte string literal not displayed */
}

Car makes a reference to a CAR file that has been potentially exported to the disk. In the case of inline preparation, the path may be empty so the Car should be constructed on the fly using CarBlock. The index on PieceCID is to find all CARs that can matches the PieceCID

type CarBlock

type CarBlock struct {
	ID             CarBlockID `cbor:"-"                    gorm:"primaryKey"                           json:"id"`
	CID            CID        `cbor:"1,keyasint,omitempty" gorm:"index;column:cid;type:bytes;size:255" json:"cid" swaggertype:"string"` // CID is the CID of the block.
	CarOffset      int64      `cbor:"2,keyasint,omitempty" json:"carOffset"`                                                            // Offset of the block in the Car
	CarBlockLength int32      `cbor:"3,keyasint,omitempty" json:"carBlockLength"`                                                       // Length of the block in the Car, including varint, CID and raw block
	Varint         []byte     `cbor:"4,keyasint,omitempty" json:"varint"`                                                               // Varint is the varint that represents the length of the block and the CID.
	RawBlock       []byte     `cbor:"5,keyasint,omitempty" json:"rawBlock"`                                                             // Raw block
	FileOffset     int64      `cbor:"6,keyasint,omitempty" json:"fileOffset"`                                                           // Offset of the block in the File

	// Associations
	CarID  CarID   `cbor:"-"                    gorm:"index"                                         json:"carId"`
	Car    *Car    `cbor:"-"                    gorm:"foreignKey:CarID;constraint:OnDelete:CASCADE"  json:"car,omitempty"  swaggerignore:"true"`
	FileID *FileID `cbor:"7,keyasint,omitempty" json:"fileId"`
	File   *File   `cbor:"-"                    gorm:"foreignKey:FileID;constraint:OnDelete:CASCADE" json:"file,omitempty" swaggerignore:"true"`
	// contains filtered or unexported fields
}

CarBlock tells us the CIDs of all blocks inside a Car and the offset of those blocks. From this table we can determine how to get the block by CID from a Car. Or we can determine how to assemble a CAR file from blocks from File. It is also possible to get all Car that are associated with File. The index on CarID is used to find all blocks in a Car. The index on CID is used to find a specific block with CID.

func (CarBlock) BlockLength

func (c CarBlock) BlockLength() int32

BlockLength computes and returns the length of the block data in bytes. If the block length has already been calculated and stored, it returns the stored value. Otherwise, it calculates the block length based on the raw block data if it is available, or by subtracting the CID byte length and varint length from the total CarBlock length.

Returns:

  • An int32 representing the length of the block data in bytes.

type CarBlockID added in v0.5.0

type CarBlockID uint64

type CarID added in v0.5.0

type CarID uint32

type ClientConfig added in v0.5.0

type ClientConfig struct {
	ConnectTimeout          *time.Duration    `cbor:"1,keyasint,omitempty"  json:"connectTimeout,omitempty"          swaggertype:"primitive,integer"` // HTTP Client Connect timeout
	Timeout                 *time.Duration    `cbor:"2,keyasint,omitempty"  json:"timeout,omitempty"                 swaggertype:"primitive,integer"` // IO idle timeout
	ExpectContinueTimeout   *time.Duration    `cbor:"3,keyasint,omitempty"  json:"expectContinueTimeout,omitempty"   swaggertype:"primitive,integer"` // Timeout when using expect / 100-continue in HTTP
	InsecureSkipVerify      *bool             `cbor:"4,keyasint,omitempty"  json:"insecureSkipVerify,omitempty"`                                      // Do not verify the server SSL certificate (insecure)
	NoGzip                  *bool             `cbor:"5,keyasint,omitempty"  json:"noGzip,omitempty"`                                                  // Don't set Accept-Encoding: gzip
	UserAgent               *string           `cbor:"6,keyasint,omitempty"  json:"userAgent,omitempty"`                                               // Set the user-agent to a specified string
	CaCert                  []string          `cbor:"7,keyasint,omitempty"  json:"caCert,omitempty"`                                                  // Paths to CA certificate used to verify servers
	ClientCert              *string           `cbor:"8,keyasint,omitempty"  json:"clientCert,omitempty"`                                              // Path to Client SSL certificate (PEM) for mutual TLS auth
	ClientKey               *string           `cbor:"9,keyasint,omitempty"  json:"clientKey,omitempty"`                                               // Path to Client SSL private key (PEM) for mutual TLS auth
	Headers                 map[string]string `cbor:"10,keyasint,omitempty" json:"headers,omitempty"`                                                 // Set HTTP header for all transactions
	DisableHTTP2            *bool             `cbor:"11,keyasint,omitempty" json:"disableHttp2,omitempty"`                                            // Disable HTTP/2 in the transport
	DisableHTTPKeepAlives   *bool             `cbor:"12,keyasint,omitempty" json:"disableHttpKeepAlives,omitempty"`                                   // Disable HTTP keep-alives and use each connection once.
	RetryMaxCount           *int              `cbor:"13,keyasint,omitempty" json:"retryMaxCount,omitempty"`                                           // Maximum number of retries. Default is 10 retries.
	RetryDelay              *time.Duration    `cbor:"14,keyasint,omitempty" json:"retryDelay,omitempty"              swaggertype:"primitive,integer"` // Delay between retries. Default is 1s.
	RetryBackoff            *time.Duration    `cbor:"15,keyasint,omitempty" json:"retryBackoff,omitempty"            swaggertype:"primitive,integer"` // Constant backoff between retries. Default is 1s.
	RetryBackoffExponential *float64          `cbor:"16,keyasint,omitempty" json:"retryBackoffExponential,omitempty"`                                 // Exponential backoff between retries. Default is 1.0.
	SkipInaccessibleFile    *bool             `cbor:"17,keyasint,omitempty" json:"skipInaccessibleFile,omitempty"`                                    // Skip inaccessible files. Default is false.
	UseServerModTime        *bool             `cbor:"18,keyasint,omitempty" json:"useServerModTime,omitempty"`                                        // Use server modified time instead of object metadata
	LowLevelRetries         *int              `cbor:"19,keyasint,omitempty" json:"lowlevelRetries,omitempty"`                                         // Maximum number of retries for low-level client errors. Default is 10 retries.
	ScanConcurrency         *int              `cbor:"20,keyasint,omitempty" json:"scanConcurrency,omitempty"`                                         // Maximum number of concurrent scan requests. Default is 1.
}

func (*ClientConfig) Scan added in v0.5.0

func (c *ClientConfig) Scan(src any) error

func (ClientConfig) String added in v0.5.0

func (c ClientConfig) String() string

func (ClientConfig) Value added in v0.5.0

func (c ClientConfig) Value() (driver.Value, error)

type ConfigMap added in v0.4.0

type ConfigMap map[string]string

func (*ConfigMap) Scan added in v0.4.0

func (m *ConfigMap) Scan(src any) error

func (ConfigMap) String added in v0.4.0

func (m ConfigMap) String() string

func (ConfigMap) Value added in v0.4.0

func (m ConfigMap) Value() (driver.Value, error)

type Deal

type Deal struct {
	ID               DealID     `gorm:"primaryKey"                      json:"id"                                  table:"verbose"`
	CreatedAt        time.Time  `json:"createdAt"                       table:"verbose;format:2006-01-02 15:04:05"`
	UpdatedAt        time.Time  `json:"updatedAt"                       table:"verbose;format:2006-01-02 15:04:05"`
	LastVerifiedAt   *time.Time `json:"lastVerifiedAt"                  table:"verbose;format:2006-01-02 15:04:05"` // LastVerifiedAt is the last time the deal was verified as active by the tracker
	DealID           *uint64    `gorm:"unique"                          json:"dealId"`
	State            DealState  `gorm:"index:idx_pending"               json:"state"`
	Provider         string     `json:"provider"`
	ProposalID       string     `json:"proposalId"                      table:"verbose"`
	Label            string     `json:"label"                           table:"verbose"`
	PieceCID         CID        `gorm:"column:piece_cid;index;size:255" json:"pieceCid"                            swaggertype:"string"`
	PieceSize        int64      `json:"pieceSize"`
	StartEpoch       int32      `json:"startEpoch"`
	EndEpoch         int32      `json:"endEpoch"                        table:"verbose"`
	SectorStartEpoch int32      `json:"sectorStartEpoch"                table:"verbose"`
	Price            string     `json:"price"`
	Verified         bool       `json:"verified"`
	ErrorMessage     string     `json:"errorMessage"                    table:"verbose"`

	// Associations
	ScheduleID *ScheduleID `json:"scheduleId"                                         table:"verbose"`
	Schedule   *Schedule   `gorm:"foreignKey:ScheduleID;constraint:OnDelete:SET NULL" json:"schedule,omitempty" swaggerignore:"true" table:"expand"`
	ClientID   string      `gorm:"index:idx_pending"                                  json:"clientId"`
	Wallet     *Wallet     `gorm:"foreignKey:ClientID;constraint:OnDelete:SET NULL"   json:"wallet,omitempty"   swaggerignore:"true" table:"expand"`
}

Deal is the deal model for all deals made by deal pusher or tracked by the tracker. The index on PieceCID is used to track replication of the same piece CID. The index on State and ClientID is used to calculate number and size of pending deals.

func (Deal) Key

func (d Deal) Key() string

Key returns a mostly unique key to match deal from locally proposed deals and deals from the chain.

type DealID added in v0.5.0

type DealID uint64

type DealState

type DealState string
const (
	DealProposed        DealState = "proposed"
	DealPublished       DealState = "published"
	DealActive          DealState = "active"
	DealExpired         DealState = "expired"
	DealProposalExpired DealState = "proposal_expired"
	DealRejected        DealState = "rejected"
	DealSlashed         DealState = "slashed"
	DealErrored         DealState = "error"
)

type Directory

type Directory struct {
	ID       DirectoryID `gorm:"primaryKey"            json:"id"`
	CID      CID         `gorm:"column:cid;type:bytes" json:"cid" swaggertype:"string"` // CID is the CID of the directory.
	Data     []byte      `gorm:"column:data"           json:"-"   swaggerignore:"true"` // Data is the serialized directory data.
	Name     string      `json:"name"`                                                  // Name is the name of the directory.
	Exported bool        `json:"exported"`                                              // Exported is a flag that indicates whether the directory has been exported to the DAG.

	// Associations
	AttachmentID SourceAttachmentID `gorm:"index:directory_source_parent"                       json:"attachmentId"`
	Attachment   *SourceAttachment  `gorm:"foreignKey:AttachmentID;constraint:OnDelete:CASCADE" json:"attachment,omitempty" swaggerignore:"true"`
	ParentID     *DirectoryID       `gorm:"index:directory_source_parent"                       json:"parentId"`
	Parent       *Directory         `gorm:"foreignKey:ParentID;constraint:OnDelete:CASCADE"     json:"parent,omitempty"     swaggerignore:"true"`
}

Directory is a link between parent and child directories. The index on AttachmentID and ParentID is used to find all root directories, as well as all directories in a directory.

type DirectoryID added in v0.5.0

type DirectoryID uint64

type File added in v0.3.0

type File struct {
	ID               FileID `cbor:"1,keyasint,omitempty" gorm:"primaryKey"                     json:"id"`
	CID              CID    `cbor:"-"                    gorm:"column:cid;type:bytes;size:255" json:"cid"  swaggertype:"string"` // CID is the CID of the file.
	Path             string `cbor:"2,keyasint,omitempty" gorm:"index"                          json:"path"`                      // Path is the relative path to the file inside the storage.
	Hash             string `cbor:"3,keyasint,omitempty" json:"hash"`                                                            // Hash is the hash of the file.
	Size             int64  `cbor:"4,keyasint,omitempty" json:"size"`                                                            // Size is the size of the file in bytes.
	LastModifiedNano int64  `cbor:"5,keyasint,omitempty" json:"lastModifiedNano"`

	// Associations
	AttachmentID SourceAttachmentID `cbor:"-" json:"attachmentId"`
	Attachment   *SourceAttachment  `cbor:"-" gorm:"foreignKey:AttachmentID;constraint:OnDelete:CASCADE" json:"attachment,omitempty" swaggerignore:"true"`
	DirectoryID  *DirectoryID       `cbor:"-" gorm:"index"                                               json:"directoryId"`
	Directory    *Directory         `cbor:"-" gorm:"foreignKey:DirectoryID;constraint:OnDelete:CASCADE"  json:"directory,omitempty"  swaggerignore:"true"`
	FileRanges   []FileRange        `cbor:"-" gorm:"constraint:OnDelete:CASCADE"                         json:"fileRanges,omitempty"`
}

File makes a reference to the source storage file, e.g., a local file. The index on Path is used as part of scanning to find existing file and add new versions. The index on DirectoryID is used to find all files in a directory.

func (File) FileName added in v0.4.0

func (i File) FileName() string

type FileID added in v0.5.0

type FileID uint64

type FileRange added in v0.3.0

type FileRange struct {
	ID     FileRangeID `gorm:"primaryKey"            json:"id"`
	Offset int64       `json:"offset"`                                                // Offset is the offset of the range inside the file.
	Length int64       `json:"length"`                                                // Length is the length of the range in bytes.
	CID    CID         `gorm:"column:cid;type:bytes" json:"cid" swaggertype:"string"` // CID is the CID of the range.

	// Associations
	JobID  *JobID `gorm:"index"                                         json:"jobId"`
	Job    *Job   `gorm:"foreignKey:JobID;constraint:OnDelete:SET NULL" json:"job,omitempty"  swaggerignore:"true"`
	FileID FileID `gorm:"index"                                         json:"fileId"`
	File   *File  `gorm:"foreignKey:FileID;constraint:OnDelete:CASCADE" json:"file,omitempty" swaggerignore:"true"`
}

FileRange is a range of bytes inside File. The index on FileID is used to find all FileRange in a file. The index on JobID is used to find all FileRange in a job.

type FileRangeID added in v0.5.0

type FileRangeID uint64

type Global

type Global struct {
	Key   string `gorm:"primaryKey" json:"key"`
	Value string `json:"value"`
}

type Job added in v0.4.0

type Job struct {
	ID              JobID    `gorm:"primaryKey"           json:"id"`
	Type            JobType  `gorm:"index:job_type_state" json:"type"`
	State           JobState `gorm:"index:job_type_state" json:"state"`
	ErrorMessage    string   `json:"errorMessage"`
	ErrorStackTrace string   `json:"errorStackTrace"      table:"verbose"`

	// Associations
	WorkerID     *string            `gorm:"size:63"                                                        json:"workerId,omitempty"`
	Worker       *Worker            `` /* 141-byte string literal not displayed */
	AttachmentID SourceAttachmentID `json:"attachmentId"                                                   table:"verbose"`
	Attachment   *SourceAttachment  `` /* 133-byte string literal not displayed */
	FileRanges   []FileRange        `` /* 128-byte string literal not displayed */
}

Job is a job that is executed by a worker. The composite index on Type and State is used to find jobs that are ready to be executed.

type JobID added in v0.5.0

type JobID uint64

type JobState added in v0.4.0

type JobState string
const (
	// Created means the job has been created is not ready for processing.
	Created JobState = "created"
	// Ready means the job is ready for processing.
	Ready JobState = "ready"
	// Paused means the job is ready but has been paused and should not be picked up for processing.
	Paused JobState = "paused"
	// Processing means the job is currently being processed.
	Processing JobState = "processing"
	// Complete means the job is complete.
	Complete JobState = "complete"
	// Error means the job has some error.
	Error JobState = "error"
)

func (*JobState) Set added in v0.4.0

func (js *JobState) Set(value string) error

func (*JobState) String added in v0.4.0

func (js *JobState) String() string

type JobType added in v0.4.0

type JobType string
const (
	Scan   JobType = "scan"
	Pack   JobType = "pack"
	DagGen JobType = "daggen"
)

type OutputAttachment added in v0.4.0

type OutputAttachment struct {
	ID OutputAttachmentID `gorm:"primaryKey" json:"id"`

	// Associations
	PreparationID PreparationID `gorm:"uniqueIndex:prep_output"                              json:"preparationId"`
	Preparation   *Preparation  `gorm:"foreignKey:PreparationID;constraint:OnDelete:CASCADE" json:"preparation,omitempty" swaggerignore:"true"`
	StorageID     StorageID     `gorm:"uniqueIndex:prep_output"                              json:"storageId"`
	Storage       *Storage      `gorm:"foreignKey:StorageID;constraint:OnDelete:CASCADE"     json:"storage,omitempty"     swaggerignore:"true"`
}

OutputAttachment is a link between a Preparation and a Storage that is used as an output.

type OutputAttachmentID added in v0.5.0

type OutputAttachmentID uint32

type Preparation added in v0.4.0

type Preparation struct {
	ID                PreparationID `gorm:"primaryKey"        json:"id"`
	Name              string        `gorm:"unique"            json:"name"`
	CreatedAt         time.Time     `json:"createdAt"         table:"verbose;format:2006-01-02 15:04:05"`
	UpdatedAt         time.Time     `json:"updatedAt"         table:"verbose;format:2006-01-02 15:04:05"`
	DeleteAfterExport bool          `json:"deleteAfterExport"` // DeleteAfterExport is a flag that indicates whether the source files should be deleted after export.
	MaxSize           int64         `json:"maxSize"`
	PieceSize         int64         `json:"pieceSize"`
	NoInline          bool          `json:"noInline"`
	NoDag             bool          `json:"noDag"`

	// Associations
	Wallets        []Wallet  `` /* 149-byte string literal not displayed */
	SourceStorages []Storage `` /* 134-byte string literal not displayed */
	OutputStorages []Storage `` /* 134-byte string literal not displayed */
}

Preparation is a data preparation definition that can attach multiple source storages and up to one output storage.

func (*Preparation) FindByIDOrName added in v0.4.0

func (s *Preparation) FindByIDOrName(db *gorm.DB, name string, preloads ...string) error

func (*Preparation) SourceAttachments added in v0.5.2

func (s *Preparation) SourceAttachments(db *gorm.DB, preloads ...string) ([]SourceAttachment, error)

type PreparationID added in v0.5.0

type PreparationID uint32

type Schedule

type Schedule struct {
	ID                    ScheduleID    `gorm:"primaryKey"                          json:"id"`
	CreatedAt             time.Time     `json:"createdAt"                           table:"verbose;format:2006-01-02 15:04:05"`
	UpdatedAt             time.Time     `json:"updatedAt"                           table:"verbose;format:2006-01-02 15:04:05"`
	URLTemplate           string        `json:"urlTemplate"                         table:"verbose"`
	HTTPHeaders           ConfigMap     `gorm:"type:JSON"                           json:"httpHeaders"                         table:"verbose"`
	Provider              string        `json:"provider"`
	PricePerGBEpoch       float64       `json:"pricePerGbEpoch"                     table:"verbose"`
	PricePerGB            float64       `json:"pricePerGb"                          table:"verbose"`
	PricePerDeal          float64       `json:"pricePerDeal"                        table:"verbose"`
	TotalDealNumber       int           `json:"totalDealNumber"                     table:"verbose"`
	TotalDealSize         int64         `json:"totalDealSize"`
	Verified              bool          `json:"verified"`
	KeepUnsealed          bool          `json:"keepUnsealed"                        table:"verbose"`
	AnnounceToIPNI        bool          `gorm:"column:announce_to_ipni"             json:"announceToIpni"                      table:"verbose"`
	StartDelay            time.Duration `json:"startDelay"                          swaggertype:"primitive,integer"`
	Duration              time.Duration `json:"duration"                            swaggertype:"primitive,integer"`
	State                 ScheduleState `json:"state"`
	ScheduleCron          string        `json:"scheduleCron"`
	ScheduleCronPerpetual bool          `json:"scheduleCronPerpetual"`
	ScheduleDealNumber    int           `json:"scheduleDealNumber"`
	ScheduleDealSize      int64         `json:"scheduleDealSize"`
	MaxPendingDealNumber  int           `json:"maxPendingDealNumber"`
	MaxPendingDealSize    int64         `json:"maxPendingDealSize"`
	Notes                 string        `json:"notes"`
	ErrorMessage          string        `json:"errorMessage"                        table:"verbose"`
	AllowedPieceCIDs      StringSlice   `gorm:"type:JSON;column:allowed_piece_cids" json:"allowedPieceCids"                    table:"verbose"`
	Force                 bool          `json:"force"`

	// Associations
	PreparationID PreparationID `json:"preparationId"`
	Preparation   *Preparation  `gorm:"foreignKey:PreparationID;constraint:OnDelete:CASCADE" json:"preparation,omitempty" swaggerignore:"true" table:"expand"`
}

type ScheduleID added in v0.5.0

type ScheduleID uint32

type ScheduleState

type ScheduleState string
const (
	ScheduleActive    ScheduleState = "active"
	SchedulePaused    ScheduleState = "paused"
	ScheduleError     ScheduleState = "error"
	ScheduleCompleted ScheduleState = "completed"
)

type SourceAttachment added in v0.4.0

type SourceAttachment struct {
	ID SourceAttachmentID `gorm:"primaryKey" json:"id"`

	// Associations
	PreparationID PreparationID `gorm:"uniqueIndex:prep_source"                              json:"preparationId"`
	Preparation   *Preparation  `gorm:"foreignKey:PreparationID;constraint:OnDelete:CASCADE" json:"preparation,omitempty" swaggerignore:"true"`
	StorageID     StorageID     `gorm:"uniqueIndex:prep_source"                              json:"storageId"`
	Storage       *Storage      `gorm:"foreignKey:StorageID;constraint:OnDelete:CASCADE"     json:"storage,omitempty"     swaggerignore:"true"`
}

SourceAttachment is a link between a Preparation and a Storage that is used as a source.

func (*SourceAttachment) FindByPreparationAndSource added in v0.4.0

func (s *SourceAttachment) FindByPreparationAndSource(db *gorm.DB, preparation string, source string) error

func (*SourceAttachment) RootDirectoryCID added in v0.4.0

func (s *SourceAttachment) RootDirectoryCID(ctx context.Context, db *gorm.DB) (cid.Cid, error)

func (*SourceAttachment) RootDirectoryID added in v0.4.0

func (s *SourceAttachment) RootDirectoryID(ctx context.Context, db *gorm.DB) (DirectoryID, error)

type SourceAttachmentID added in v0.5.0

type SourceAttachmentID uint32

type Storage added in v0.4.0

type Storage struct {
	ID           StorageID    `cbor:"-"                    gorm:"primaryKey" json:"id"`
	Name         string       `cbor:"-"                    gorm:"unique"     json:"name"`
	CreatedAt    time.Time    `cbor:"-"                    json:"createdAt"  table:"verbose;format:2006-01-02 15:04:05"`
	UpdatedAt    time.Time    `cbor:"-"                    json:"updatedAt"  table:"verbose;format:2006-01-02 15:04:05"`
	Type         string       `cbor:"1,keyasint,omitempty" json:"type"`
	Path         string       `cbor:"2,keyasint,omitempty" json:"path"`                                                                  // Path is the path to the storage root.
	Config       ConfigMap    `cbor:"3,keyasint,omitempty" gorm:"type:JSON"  json:"config"                              table:"verbose"` // Config is a map of key-value pairs that can be used to store RClone options.
	ClientConfig ClientConfig `cbor:"4,keyasint,omitempty" gorm:"type:JSON"  json:"clientConfig"                        table:"verbose"` // ClientConfig is the HTTP configuration for the storage, if applicable.

	// Associations
	PreparationsAsSource []Preparation `` /* 144-byte string literal not displayed */
	PreparationsAsOutput []Preparation `` /* 144-byte string literal not displayed */
}

Storage is a storage system definition that can be used as either source or output of a Preparation.

func (*Storage) FindByIDOrName added in v0.4.0

func (s *Storage) FindByIDOrName(db *gorm.DB, name string, preloads ...string) error

type StorageID added in v0.5.0

type StorageID uint32

type StringSlice

type StringSlice []string

func (*StringSlice) Scan

func (ss *StringSlice) Scan(src any) error

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

type Wallet

type Wallet struct {
	ID         string `gorm:"primaryKey;size:15"   json:"id"`      // ID is the short ID of the wallet
	Address    string `gorm:"index"                json:"address"` // Address is the Filecoin full address of the wallet
	PrivateKey string `json:"privateKey,omitempty" table:"-"`      // PrivateKey is the private key of the wallet
}

type Worker

type Worker struct {
	ID            string     `gorm:"primaryKey"    json:"id"`
	LastHeartbeat time.Time  `json:"lastHeartbeat"`
	Hostname      string     `json:"hostname"`
	Type          WorkerType `json:"type"`
}

type WorkerType added in v0.4.0

type WorkerType string
const (
	DealTracker   WorkerType = "deal_tracker"
	DealPusher    WorkerType = "deal_pusher"
	DatasetWorker WorkerType = "dataset_worker"
)

Jump to

Keyboard shortcuts

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