repository

package
v0.0.0-...-7404c28 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package repository is interface and its implementation for different repositories

Index

Constants

This section is empty.

Variables

View Source
var ErrNoFileInMaster = errors.New("file not found in master")

ErrNoFileInMaster is error of no file in master

Functions

func GetContentLevelID

func GetContentLevelID(r *http.Request) (uint32, uint32, error)

GetContentLevelID get content level id, including app id and template space id

func GetFileSign

func GetFileSign(r *http.Request) (string, error)

GetFileSign get file sha256

func GetMultipartUploadID

func GetMultipartUploadID(r *http.Request) (string, error)

GetMultipartUploadID get multipart upload id

func GetPartNum

func GetPartNum(r *http.Request) (uint32, error)

GetPartNum get multipart upload part num

Types

type BaseProvider

type BaseProvider interface {
	ObjectDownloader
	Upload(kt *kit.Kit, sign string, body io.Reader) (*ObjectMetadata, error)
	InitMultipartUpload(kt *kit.Kit, sign string) (string, error)
	MultipartUpload(kt *kit.Kit, sign string, uploadID string, partNum uint32, body io.Reader) error
	CompleteMultipartUpload(kt *kit.Kit, sign string, uploadID string) (*ObjectMetadata, error)
	Download(kt *kit.Kit, sign string) (io.ReadCloser, int64, error)
	Metadata(kt *kit.Kit, sign string) (*ObjectMetadata, error)
}

BaseProvider repo base provider interface

type DecoratorInter

type DecoratorInter interface {
	Root() string
	RepoName() string
	Path(sign string) string
	RelativePath(sign string) string
	Url() string
}

DecoratorInter ..

type HAEnhancer

type HAEnhancer interface {
	SyncManager() *SyncManager
}

HAEnhancer high availability enhancer interface

type MetadataResponse

type MetadataResponse struct {
	Exists   bool            `json:"exists"`
	Metadata *ObjectMetadata `json:"metadata"`
}

MetadataResponse 文件元数据响应

type ObjectDownloader

type ObjectDownloader interface {
	DownloadLink(kt *kit.Kit, sign string, fetchLimit uint32) ([]string, error)
	AsyncDownload(kt *kit.Kit, sign string) (string, error)
	AsyncDownloadStatus(kt *kit.Kit, sign string, taskID string) (bool, error)
	URIDecorator(bizID uint32) DecoratorInter
}

ObjectDownloader 文件下载

type ObjectMetadata

type ObjectMetadata struct {
	ByteSize int64  `json:"byte_size"`
	Sha256   string `json:"sha256"`
	Md5      string `json:"md5"`
}

ObjectMetadata 文件元数据

type Provider

type Provider interface {
	BaseProvider
	HAEnhancer
	VariableCacher
}

Provider repo provider interface

func NewProvider

func NewProvider(conf cc.Repository) (Provider, error)

NewProvider init provider factory by storage type

type RepoCreated

type RepoCreated struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RepoCreated is the created repo data with lock to keep its concurrent security

func (*RepoCreated) Exist

func (r *RepoCreated) Exist(name string) bool

Exist check kv

func (*RepoCreated) Set

func (r *RepoCreated) Set(name string)

Set sets kv

type SyncManager

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

SyncManager is sync manager

func (*SyncManager) AckQueueName

func (s *SyncManager) AckQueueName() string

AckQueueName returns name of ack queue

func (*SyncManager) ParseQueueMsg

func (s *SyncManager) ParseQueueMsg(msg string) (uint32, string, error)

ParseQueueMsg parses msg of sync queue

func (*SyncManager) PushToQueue

func (s *SyncManager) PushToQueue(kt *kit.Kit, sign string) error

PushToQueue pushes the file metadata msg to queue so that the master's write operations can be received by slave

func (*SyncManager) QueueClient

func (s *SyncManager) QueueClient() bedis.Client

QueueClient returns client for sync queue

func (*SyncManager) QueueMsg

func (s *SyncManager) QueueMsg(bizID uint32, sign string) string

QueueMsg returns msg for sync queue

func (*SyncManager) QueueName

func (s *SyncManager) QueueName() string

QueueName returns name of sync queue

func (*SyncManager) Sync

func (s *SyncManager) Sync(kt *kit.Kit, sign string) (skip bool, err error)

Sync syncs file from master to slave

type VariableCacher

type VariableCacher interface {
	// SetVariables sets template variables into cache, the variables extracted from repository file content
	SetVariables(kt *kit.Kit, sign string, checkSize bool) ([]string, error)
	// GetVariables gets template variables from the cache firstly; if not found, then get from the repository
	GetVariables(kt *kit.Kit, sign string, checkSize bool) ([]string, error)
}

VariableCacher is used to set/get template variables with cache

Jump to

Keyboard shortcuts

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