storage

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: 9 Imported by: 0

Documentation

Overview

Package storage

@author: xwc1125

  • 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

View Source
const (
	// SkippedValueEtcdInitDir indicates the init_dir
	// etcd event will be skipped.
	SkippedValueEtcdInitDir = "init_dir"

	// SkippedValueEtcdEmptyObject indicates the data with an
	// empty JSON value {}, which may be set by APISIX,
	// should be also skipped.
	//
	// Important: at present, {} is considered as invalid,
	// but may be changed in the future.
	SkippedValueEtcdEmptyObject = "{}"
)

Variables

View Source
var (
	Client *clientv3.Client
)

Functions

func Close

func Close() error

func InitETCDClient

func InitETCDClient(etcdConf *EtcdConfig) error

Types

type EtcdConfig

type EtcdConfig struct {
	Endpoints []string `json:"endpoints" mapstructure:"endpoints" yaml:"endpoints"`
	Username  string   `json:"username" mapstructure:"username" yaml:"username"`
	Password  string   `json:"password" mapstructure:"password" yaml:"password"`
	Tls       *Tls     `json:"tls" mapstructure:"tls" yaml:"tls"`
	Prefix    string   `json:"prefix" mapstructure:"prefix" yaml:"prefix"`
}

type EtcdV3Storage

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

func GenEtcdStorage

func GenEtcdStorage() *EtcdV3Storage

func NewETCDStorage

func NewETCDStorage(etcdConf *EtcdConfig) (*EtcdV3Storage, error)

func (*EtcdV3Storage) BatchDelete

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

func (*EtcdV3Storage) Close

func (s *EtcdV3Storage) Close() error

func (*EtcdV3Storage) Create

func (s *EtcdV3Storage) Create(ctx context.Context, key, val string) error

func (*EtcdV3Storage) Get

func (s *EtcdV3Storage) Get(ctx context.Context, key string) (string, error)

func (*EtcdV3Storage) List

func (s *EtcdV3Storage) List(ctx context.Context, key string) ([]Keypair, error)

func (*EtcdV3Storage) Update

func (s *EtcdV3Storage) Update(ctx context.Context, key, val string) error

func (*EtcdV3Storage) Watch

func (s *EtcdV3Storage) Watch(ctx context.Context, key string) <-chan WatchResponse

type Event

type Event struct {
	Keypair
	Type EventType
}

type EventType

type EventType string
var (
	EventTypePut    EventType = "put"
	EventTypeDelete EventType = "delete"
)

type Interface

type Interface interface {
	Get(ctx context.Context, key string) (string, error)
	List(ctx context.Context, key string) ([]Keypair, error)
	Create(ctx context.Context, key, val string) error
	Update(ctx context.Context, key, val string) error
	BatchDelete(ctx context.Context, keys []string) error
	Watch(ctx context.Context, key string) <-chan WatchResponse
}

type Keypair

type Keypair struct {
	Key   string
	Value string
}

type MockInterface

type MockInterface struct {
	mock.Mock
}

MockInterface is an autogenerated mock type for the Interface type

func (*MockInterface) BatchDelete

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

BatchDelete provides a mock function with given fields: ctx, keys

func (*MockInterface) Create

func (_m *MockInterface) Create(ctx context.Context, key string, val string) error

Create provides a mock function with given fields: ctx, key, val

func (*MockInterface) Get

func (_m *MockInterface) Get(ctx context.Context, key string) (string, error)

Get provides a mock function with given fields: ctx, key

func (*MockInterface) List

func (_m *MockInterface) List(ctx context.Context, key string) ([]Keypair, error)

List provides a mock function with given fields: ctx, key

func (*MockInterface) Update

func (_m *MockInterface) Update(ctx context.Context, key string, val string) error

Update provides a mock function with given fields: ctx, key, val

func (*MockInterface) Watch

func (_m *MockInterface) Watch(ctx context.Context, key string) <-chan WatchResponse

Watch provides a mock function with given fields: ctx, key

type Tls

type Tls struct {
	CaFile   string `json:"ca" mapstructure:"ca" yaml:"ca"`
	CertFile string `json:"cert" mapstructure:"cert" yaml:"cert"`
	KeyFile  string `json:"key" mapstructure:"key" yaml:"key"`
}

type WatchResponse

type WatchResponse struct {
	Events   []Event
	Error    error
	Canceled bool
}

Jump to

Keyboard shortcuts

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