store

package
v0.0.0-...-ae88a46 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.

* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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

This section is empty.

Variables

This section is empty.

Functions

func InitStore

func InitStore(schema gjson.Result, key HubKey, opt GenericStoreOption) error

func InitStores

func InitStores(schema gjson.Result, conf storage.EtcdConfig, watchEvents map[HubKey]WatchEvent) error

func RangeStore

func RangeStore(f func(key HubKey, store *GenericStore) bool)

Types

type APISIXJsonSchemaValidator

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

func (*APISIXJsonSchemaValidator) Validate

func (v *APISIXJsonSchemaValidator) Validate(obj interface{}) error

type APISIXSchemaValidator

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

func (*APISIXSchemaValidator) Validate

func (v *APISIXSchemaValidator) Validate(obj interface{}) error

type GenericStore

type GenericStore struct {
	Stg storage2.Interface
	// contains filtered or unexported fields
}

func GetStore

func GetStore(key HubKey) *GenericStore

func NewGenericStore

func NewGenericStore(opt GenericStoreOption) (*GenericStore, error)

func (*GenericStore) BatchDelete

func (s *GenericStore) BatchDelete(ctx context.Context, keys []string) error

func (*GenericStore) Close

func (s *GenericStore) Close() error

func (*GenericStore) Create

func (s *GenericStore) Create(ctx context.Context, obj interface{}) (interface{}, error)

func (*GenericStore) CreateCheck

func (s *GenericStore) CreateCheck(obj interface{}) ([]byte, error)

func (*GenericStore) Get

func (s *GenericStore) Get(_ context.Context, key string) (interface{}, error)

func (*GenericStore) GetObjStorageKey

func (s *GenericStore) GetObjStorageKey(obj interface{}) string

func (*GenericStore) GetStorageKey

func (s *GenericStore) GetStorageKey(key string) string

func (*GenericStore) Init

func (s *GenericStore) Init() error

func (*GenericStore) List

func (s *GenericStore) List(_ context.Context, input ListInput) (*ListOutput, error)

func (*GenericStore) Range

func (s *GenericStore) Range(_ context.Context, f func(key string, obj interface{}) bool)

func (*GenericStore) StringToObjPtr

func (s *GenericStore) StringToObjPtr(str, key string) (interface{}, error)

func (*GenericStore) Type

func (s *GenericStore) Type() HubKey

func (*GenericStore) Update

func (s *GenericStore) Update(ctx context.Context, obj interface{}, createIfNotExist bool) (interface{}, error)

type GenericStoreOption

type GenericStoreOption struct {
	BasePath   string
	ObjType    reflect.Type
	KeyFunc    func(obj interface{}) string
	StockCheck func(obj interface{}, stockObj interface{}) error
	Validator  Validator
	HubKey     HubKey

	WatchEvent WatchEvent
}

type HubKey

type HubKey string
const (
	HubKeyConsumer     HubKey = "consumer"
	HubKeyRoute        HubKey = "route"
	HubKeyService      HubKey = "service"
	HubKeySsl          HubKey = "ssl"
	HubKeyUpstream     HubKey = "upstream"
	HubKeyScript       HubKey = "script"
	HubKeyGlobalRule   HubKey = "global_rule"
	HubKeyServerInfo   HubKey = "server_info"
	HubKeyPluginConfig HubKey = "plugin_config"
	HubKeyProto        HubKey = "proto"
	HubKeyStreamRoute  HubKey = "stream_route"
)

type Interface

type Interface interface {
	Type() HubKey
	Get(ctx context.Context, key string) (interface{}, error)                                // 通过key查询
	List(ctx context.Context, input ListInput) (*ListOutput, error)                          // 查询list
	Create(ctx context.Context, obj interface{}) (interface{}, error)                        // 创建
	Update(ctx context.Context, obj interface{}, createIfNotExist bool) (interface{}, error) // 更新
	BatchDelete(ctx context.Context, keys []string) error                                    // 批量删除
}

type JsonSchemaValidator

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

func (*JsonSchemaValidator) Validate

func (v *JsonSchemaValidator) Validate(obj interface{}) error

type ListInput

type ListInput struct {
	Predicate func(obj interface{}) bool
	Format    func(obj interface{}) interface{}
	PageSize  int
	// start from 1
	PageNumber int
	Less       func(i, j interface{}) bool
}

type ListOutput

type ListOutput struct {
	Rows      []interface{} `json:"rows"`
	TotalSize int           `json:"total_size"`
}

func NewListOutput

func NewListOutput() *ListOutput

NewListOutput returns JSON marshalling safe struct pointer for empty slice

type MockInterface

type MockInterface struct {
	mock.Mock
	HubKey HubKey
}

func (*MockInterface) BatchDelete

func (m *MockInterface) BatchDelete(ctx context.Context, keys []string) error

func (*MockInterface) Create

func (m *MockInterface) Create(ctx context.Context, obj interface{}) (interface{}, error)

func (*MockInterface) Get

func (m *MockInterface) Get(_ context.Context, key string) (interface{}, error)

func (*MockInterface) List

func (m *MockInterface) List(_ context.Context, input ListInput) (*ListOutput, error)

func (*MockInterface) Type

func (m *MockInterface) Type() HubKey

func (*MockInterface) Update

func (m *MockInterface) Update(ctx context.Context, obj interface{}, createOnFail bool) (interface{}, error)

type MockValidator

type MockValidator struct {
	mock.Mock
}

MockValidator is an autogenerated mock type for the Validator type

func (*MockValidator) Validate

func (_m *MockValidator) Validate(obj interface{}) error

Validate provides a mock function with given fields: obj

type Pagination

type Pagination struct {
	PageSize   int `json:"page_size" form:"page_size" auto_read:"page_size"`
	PageNumber int `json:"page" form:"page" auto_read:"page"`
}

type Validator

type Validator interface {
	Validate(obj interface{}) error
}

func NewAPISIXJsonSchemaValidator

func NewAPISIXJsonSchemaValidator(schema gjson.Result, jsonPath string) (Validator, error)

func NewAPISIXSchemaValidator

func NewAPISIXSchemaValidator(schema gjson.Result, jsonPath string) (Validator, error)

func NewJsonSchemaValidator

func NewJsonSchemaValidator(jsonPath string) (Validator, error)

func NewSchemaValidator

func NewSchemaValidator(schemaJson string) (Validator, error)

type WatchEvent

type WatchEvent interface {
	WatchEventPut(key string, objPtr interface{})
	WatchEventDelete(key string)
}

Jump to

Keyboard shortcuts

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