preheat

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright The Dragonfly Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	// preheat image cache one week
	EXPIRED_TIME = 7 * 24 * 3600 * 1000
)
View Source
const TIMEOUT = 30 * 60

Variables

View Source
var IMAGE_MANIFESTS_PATTERN, _ = regexp.Compile("^(.*)://(.*)/v2/(.*)/manifests/(.*)")

Functions

func NewManager

func NewManager(cfg *config.Config) (mgr.PreheatManager, error)

func RegisterPreheater

func RegisterPreheater(typ string, preheater Preheater)

Types

type BasePreheater

type BasePreheater struct{}

func (*BasePreheater) Cancel

func (p *BasePreheater) Cancel(id string)

*

  • cancel the running task

func (*BasePreheater) NewWorker

func (p *BasePreheater) NewWorker(task *mgr.PreheatTask, service *PreheatService) IWorker

*

  • Create a worker to preheat the task.

func (*BasePreheater) Remove

func (p *BasePreheater) Remove(id string)

*

  • remove a running preheat task

func (*BasePreheater) Type

func (p *BasePreheater) Type() string

*

  • The type of this preheater

type BaseWorker

type BaseWorker struct {
	Task           *mgr.PreheatTask
	Preheater      Preheater
	PreheatService *PreheatService
	// contains filtered or unexported fields
}

func (*BaseWorker) Run

func (w *BaseWorker) Run()

func (*BaseWorker) Stop

func (w *BaseWorker) Stop()

type FilePreheat

type FilePreheat struct {
	*BasePreheater
}

func (*FilePreheat) NewWorker

func (p *FilePreheat) NewWorker(task *mgr.PreheatTask, service *PreheatService) IWorker

*

  • Create a worker to preheat the task.

func (*FilePreheat) Type

func (p *FilePreheat) Type() string

type FileWorker

type FileWorker struct {
	*BaseWorker
	// contains filtered or unexported fields
}

type IWorker

type IWorker interface {
	Run()
	Stop()
	// contains filtered or unexported methods
}

type ImagePreheat

type ImagePreheat struct {
	*BasePreheater
}

func (*ImagePreheat) NewWorker

func (p *ImagePreheat) NewWorker(task *mgr.PreheatTask, service *PreheatService) IWorker

*

  • Create a worker to preheat the task.

func (*ImagePreheat) Type

func (p *ImagePreheat) Type() string

type ImageWorker

type ImageWorker struct {
	*BaseWorker
	// contains filtered or unexported fields
}

type Layer

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

type Manager

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

Manager is an implementation of interface PreheatManager.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, task *types.PreheatCreateRequest) (preheatID string, err error)

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, preheatID string) (err error)

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, preheatID string) (preheatTask *mgr.PreheatTask, err error)

func (*Manager) GetAll

func (m *Manager) GetAll(ctx context.Context) (preheatTasks []*mgr.PreheatTask, err error)

type PreheatProgress

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

func NewPreheatProgress

func NewPreheatProgress(output string, cmd *exec.Cmd) *PreheatProgress

type PreheatService

type PreheatService struct {
	PreheatPath string
	// contains filtered or unexported fields
}

func NewPreheatService

func NewPreheatService(homeDir string) *PreheatService

func (*PreheatService) Create

func (svc *PreheatService) Create(task *mgr.PreheatTask) (string, error)

create a preheat task

func (*PreheatService) Delete

func (svc *PreheatService) Delete(id string)

Delete a preheat task.

func (*PreheatService) ExecutePreheat

func (svc *PreheatService) ExecutePreheat(task *mgr.PreheatTask) (progress *PreheatProgress, err error)

execute preheat task

func (*PreheatService) Get

func (svc *PreheatService) Get(id string) *mgr.PreheatTask

Get detailed preheat task information

func (*PreheatService) GetAll

func (svc *PreheatService) GetAll() []*mgr.PreheatTask

Get all preheat tasks

func (*PreheatService) Update

func (svc *PreheatService) Update(id string, task *mgr.PreheatTask) bool

update a preheat task

type PreheatTaskRepository

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

func NewPreheatTaskRepository

func NewPreheatTaskRepository() *PreheatTaskRepository

func (*PreheatTaskRepository) Add

func (*PreheatTaskRepository) Delete

func (r *PreheatTaskRepository) Delete(id string) bool

func (*PreheatTaskRepository) Get

func (*PreheatTaskRepository) GetAll

func (r *PreheatTaskRepository) GetAll() []*mgr.PreheatTask

func (*PreheatTaskRepository) GetAllIds

func (r *PreheatTaskRepository) GetAllIds() []string

func (*PreheatTaskRepository) IsExpired

func (r *PreheatTaskRepository) IsExpired(id string) bool

func (*PreheatTaskRepository) Update

func (r *PreheatTaskRepository) Update(id string, task *mgr.PreheatTask) bool

type Preheater

type Preheater interface {
	/**
	 * The type of this preheater
	 */
	Type() string

	/**
	 * Create a worker to preheat the task.
	 */
	NewWorker(task *mgr.PreheatTask, service *PreheatService) IWorker

	/**
	 * cancel the running task
	 */
	Cancel(id string)

	/**
	 * remove a running preheat task
	 */
	Remove(id string)
}

func GetPreheater

func GetPreheater(typ string) Preheater

Jump to

Keyboard shortcuts

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