factory

package
v0.0.0-...-7077701 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p 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.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p 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.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use p 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

This section is empty.

Variables

View Source
var (
	ErrObjectNotFound       = errors.New("object not found")
	ErrObjectAlreadyExist   = errors.New("object already exist")
	ErrObjectInvalidArg     = errors.New("invalid object args")
	ErrFactoryInternalError = errors.New("object factory internal")
)

Functions

func Error

func Error(db *gorm.DB) error

func Initialize

func Initialize(servingOptions *modeloptions.ServingOptions)

Initialize will be called in startup to initialize all internal model factory

func NewCacheID

func NewCacheID(owner Owner, additionals ...string) string

func RegisterFactory

func RegisterFactory(model interface{}, f Factory)

RegisterFactory will add model factory. user can also add customized model factory

Types

type Factory

type Factory interface {
	// Save a newly created object into factory
	Save(Owner, models.Model) (models.Model, error)
	// List return object sets accoroding to query
	List(Owner, *models.Query) ([]models.Model, error)
	// Get return a specified object
	Get(Owner, string) (models.Model, error)
	// Delete will delete specified object in factory
	Delete(Owner, string) error
	// Update update object in factory
	Update(Owner, models.Model) error
}

Factory will create and manage object

func NewFactory

func NewFactory(obj interface{}) Factory

NewFactory create and return model factory

type Owner

type Owner interface {
	WithProject(string) Owner
	WithWorkshop(string) Owner
	User() string
	Project() string
	Workshop() string
}

func NewOwner

func NewOwner(userId string) Owner

Jump to

Keyboard shortcuts

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