disk

package
v0.0.131 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.

Index

Constants

View Source
const (
	DefaultCheckInterval       time.Duration = time.Minute
	DefaultbaseExpired         time.Duration = 72 * time.Hour
	DefalutRandomizationFactor               = 0.1
	DefalutMultiplier                        = 0.8
	DefalutMinInterval                       = time.Minute
)

Variables

View Source
var File_pkg_file_cleanup_disk_disk_cleaner_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type DiskCleaner

type DiskCleaner struct {
	Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"`
	// disk usage >= disk_usage, start to clean file, 0 means nerver clean, range
	// 0-100
	DiskUsage float32 `protobuf:"fixed32,2,opt,name=disk_usage,json=diskUsage,proto3" json:"disk_usage,omitempty"`
	// clearn paths
	Paths []string `protobuf:"bytes,3,rep,name=paths,proto3" json:"paths,omitempty"`
	// ext
	Exts          []string           `protobuf:"bytes,4,rep,name=exts,proto3" json:"exts,omitempty"`
	CheckInterval *duration.Duration `protobuf:"bytes,5,opt,name=check_interval,json=checkInterval,proto3" json:"check_interval,omitempty"`
	BaseExpired   *duration.Duration `protobuf:"bytes,6,opt,name=base_expired,json=baseExpired,proto3" json:"base_expired,omitempty"`
	MinExpired    *duration.Duration `protobuf:"bytes,7,opt,name=min_expired,json=minExpired,proto3" json:"min_expired,omitempty"`
	// contains filtered or unexported fields
}

func (*DiskCleaner) Descriptor deprecated

func (*DiskCleaner) Descriptor() ([]byte, []int)

Deprecated: Use DiskCleaner.ProtoReflect.Descriptor instead.

func (*DiskCleaner) GetBaseExpired

func (x *DiskCleaner) GetBaseExpired() *duration.Duration

func (*DiskCleaner) GetCheckInterval

func (x *DiskCleaner) GetCheckInterval() *duration.Duration

func (*DiskCleaner) GetDiskUsage

func (x *DiskCleaner) GetDiskUsage() float32

func (*DiskCleaner) GetEnabled

func (x *DiskCleaner) GetEnabled() bool

func (*DiskCleaner) GetExts

func (x *DiskCleaner) GetExts() []string

func (*DiskCleaner) GetMinExpired

func (x *DiskCleaner) GetMinExpired() *duration.Duration

func (*DiskCleaner) GetPaths

func (x *DiskCleaner) GetPaths() []string

func (*DiskCleaner) ProtoMessage

func (*DiskCleaner) ProtoMessage()

func (*DiskCleaner) ProtoReflect

func (x *DiskCleaner) ProtoReflect() protoreflect.Message

func (*DiskCleaner) Reset

func (x *DiskCleaner) Reset()

func (*DiskCleaner) String

func (x *DiskCleaner) String() string

type DiskCleanerConfig

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

func (*DiskCleanerConfig) ApplyOptions

func (o *DiskCleanerConfig) ApplyOptions(options ...DiskCleanerConfigOption) *DiskCleanerConfig

type DiskCleanerConfigOption

type DiskCleanerConfigOption interface {
	// contains filtered or unexported methods
}

A DiskCleanerConfigOption sets options.

func WithCleanPostCallBack

func WithCleanPostCallBack(f func(file string, err error)) DiskCleanerConfigOption

func WithDiskBaseExpired

func WithDiskBaseExpired(expired time.Duration) DiskCleanerConfigOption

func WithDiskCheckInterval

func WithDiskCheckInterval(interval time.Duration) DiskCleanerConfigOption

func WithDiskMinExpired

func WithDiskMinExpired(expired time.Duration) DiskCleanerConfigOption

func WithDiskUsageCallBack

func WithDiskUsageCallBack(f func(diskPath string, diskUsage float32)) DiskCleanerConfigOption

type DiskCleanerConfigOptionFunc

type DiskCleanerConfigOptionFunc func(*DiskCleanerConfig)

DiskCleanerConfigOptionFunc wraps a function that modifies Client into an implementation of the DiskCleanerConfigOption interface.

type DiskCleanerSerivce

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

DiskCleanerSerivce ...

func NewDiskCleanerSerivce

func NewDiskCleanerSerivce(
	diskUsage float32,
	paths []string,
	exts []string,
	opts ...DiskCleanerConfigOption,
) (*DiskCleanerSerivce, error)

NewDiskCleanerSerivce ...

func (*DiskCleanerSerivce) Run

Run will initialize the backend. It must not block, but may run go routines in the background.

func (*DiskCleanerSerivce) Serve

func (s *DiskCleanerSerivce) Serve(ctx context.Context) error

Serve ...

func (*DiskCleanerSerivce) Shutdown

func (s *DiskCleanerSerivce) Shutdown()

Shutdown ...

type EmptyDiskCleanerConfigOption

type EmptyDiskCleanerConfigOption struct{}

EmptyDiskCleanerConfigOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

Jump to

Keyboard shortcuts

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