cache

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cache consists of all caching relted functions and data structures.

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.

Package cache consists of all caching relted functions and data structures.

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.

Package cache consists of all caching relted functions and data structures.

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.

Package cache consists of all caching relted functions and data structures.

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.

Package cache consists of all caching relted functions and data structures.

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.

Package helper consists of helping functions.

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.

Package cache consists of all caching relted functions and data structures.

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.

Package cache consists of all caching relted functions and data structures.

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APICall

type APICall interface {
	Call() (interface{}, error)
}

APICall is a simple interface for all simplified REST API calls

func NewCachedAPICall

func NewCachedAPICall(apiCall APICall) APICall

NewCachedAPICall creates an initialized CachedAPICall object

func NewContainerCall

func NewContainerCall(auth *api.AuthenticationConfig) APICall

NewContainerCall creates an initialized ContainerCall object

func NewODCall

func NewODCall(ac *AutoContainer, schema string) APICall

NewODCall creates an initialized ODCall object

func NewSandboxCall

func NewSandboxCall(auth *api.AuthenticationConfig) APICall

NewSandboxCall creates an initialized SandboxCall object

type AutoContainer

type AutoContainer struct {
	ContainerID string
	Auth        *api.AuthenticationConfig
	// contains filtered or unexported fields
}

AutoContainer resolves autmatically the container id

func NewAutoContainer

func NewAutoContainer(auth *api.AuthenticationConfig, pp util.PathProvider) *AutoContainer

func (*AutoContainer) AddContainerFlag

func (a *AutoContainer) AddContainerFlag(cmd *cobra.Command) error

AddContainerFlag adds the required container flags to the passed command

func (*AutoContainer) Get

func (a *AutoContainer) Get() (string, error)

Get retrieves the container id

type CachedAPICall

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

CachedAPICall just stores a copy of the response if call was successful. Implements APICall interface.

func (*CachedAPICall) Call

func (c *CachedAPICall) Call() (interface{}, error)

Call is the entry point

type ContainerCall

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

ContainerCall encapsulates the call of the container service

func (*ContainerCall) Call

func (c *ContainerCall) Call() (interface{}, error)

Call is the entry point

type EatByList

type EatByList struct {
	List    []string
	Expires time.Time
}

EatByList stores data with an expiry date

func (*EatByList) Valid

func (c *EatByList) Valid() bool

func (*EatByList) ValidIn

func (c *EatByList) ValidIn(d time.Duration) bool

ValidIn in checks if the token is still valid for passed duration

type EatByMap

type EatByMap struct {
	Map     util.Mapper
	Expires time.Time
}

EatByMap stores data with an expiry date

func (*EatByMap) Valid

func (c *EatByMap) Valid() bool

Valid checks if the token is still valid

func (*EatByMap) ValidIn

func (c *EatByMap) ValidIn(d time.Duration) bool

ValidIn checks if the token is still valid for passed duration

type ListFileCache

type ListFileCache struct {
	API      APICall
	Duration time.Duration
	// contains filtered or unexported fields
}

func NewListFileCache

func NewListFileCache(apiCall APICall, trans *TransformList, d time.Duration, file util.Path) *ListFileCache

func NewSandboxCache

func NewSandboxCache(auth *api.AuthenticationConfig, pp util.PathProvider) *ListFileCache

NewSandboxCache creates an initilzed ListFileCache object for lists of sandboxes

func (*ListFileCache) Delete

func (c *ListFileCache) Delete() error

Delete deletes the corresponding file

func (*ListFileCache) Load

func (c *ListFileCache) Load() error

Load loads the cache

func (*ListFileCache) Values

func (c *ListFileCache) Values() []string

type MapFileCache

type MapFileCache struct {
	API      APICall
	Duration time.Duration
	// contains filtered or unexported fields
}

MapFileCache is a file cache for maps

func NewContainerCache

func NewContainerCache(auth *api.AuthenticationConfig, pp util.PathProvider) *MapFileCache

NewContainerCache creates a new container cache

func NewMapFileCache

func NewMapFileCache(apiCall APICall, trans *TransformMap, d time.Duration, file util.Path) *MapFileCache

NewMapFileCache creates an intialized MapFileCache object

func NewODNameToID

func NewODNameToID(ac *AutoContainer, name, schema string, pp util.PathProvider) *MapFileCache

NewODNameToID creates an initialzed MapFileCache object with a xdm:name -> @id

func NewODNameToInstanceID

func NewODNameToInstanceID(ac *AutoContainer, name, schema string, pp util.PathProvider) *MapFileCache

NewODNameToInstanceID creates an initialzed MapFileCache object with a xdm:name -> instanceId

func (*MapFileCache) Delete

func (c *MapFileCache) Delete()

DeleteE deletes the corresponding file

func (*MapFileCache) DeleteE

func (c *MapFileCache) DeleteE() error

DeleteE deletes the corresponding file

func (*MapFileCache) Keys

func (c *MapFileCache) Keys() []string

Keys returns all keys from the map

func (*MapFileCache) Load

func (c *MapFileCache) Load() error

Load loads the cache

func (*MapFileCache) Lookup

func (c *MapFileCache) Lookup(key string) string

Lookup returns either the related value or the key itself

func (*MapFileCache) LookupE

func (c *MapFileCache) LookupE(key string) (string, error)

LookupE returns either the related value or an error

func (*MapFileCache) Values

func (c *MapFileCache) Values() []string

Values returns all values from the map

type MapMemCache

type MapMemCache struct {
	API APICall
	// contains filtered or unexported fields
}

MapMemCache stores a mapper object im memory

func NewMapMemCache

func NewMapMemCache(apiCall APICall, trans *TransformMap) *MapMemCache

NewMapMemCache creates an initialized MapMemCache object

func NewODNameToIDMem

func NewODNameToIDMem(ac *AutoContainer, schema string) *MapMemCache

NewODNameToIDMem creates an initialzed MemCache object with a xdm:name -> @id

func NewODNameToInstanceIDMem

func NewODNameToInstanceIDMem(ac *AutoContainer, schema string) *MapMemCache

NewODNameToIDMem creates an initialzed MemCache object with a xdm:name -> instanceId

func (*MapMemCache) Delete

func (c *MapMemCache) Delete() error

Delete just empties the cache

func (*MapMemCache) Keys

func (c *MapMemCache) Keys() []string

Keys returns all keys from the map

func (*MapMemCache) Load

func (c *MapMemCache) Load() error

Load loads the cache

func (*MapMemCache) Lookup

func (c *MapMemCache) Lookup(key string) string

LookupE returns either the related value or the key

func (*MapMemCache) LookupE

func (c *MapMemCache) LookupE(key string) (string, error)

LookupE returns either the related value or an error

func (*MapMemCache) Mapper added in v0.3.0

func (c *MapMemCache) Mapper() util.Mapper

func (*MapMemCache) Values

func (c *MapMemCache) Values() []string

Values returns all values from the map

type ODCall

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

ODCall is a generic encapsulation for all offer decisioning calls

func (*ODCall) Call

func (c *ODCall) Call() (interface{}, error)

Call is the entry point

type SandboxCall

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

SandboxCall encapsulates the sandbox list call

func (*SandboxCall) Call

func (c *SandboxCall) Call() (interface{}, error)

Call is the entry point

type TransformList

type TransformList struct {
	Path  []string
	Value []string
}

TransformList transforms a JSON response to a list

func NewTransformList

func NewTransformList(p ...string) *TransformList

NewTransformList creates an initialized TransformList object

func (*TransformList) P

func (c *TransformList) P(p ...string) *TransformList

P provides the path to the rangable list inside the JSON file

func (TransformList) Transform

func (c TransformList) Transform(obj interface{}) []string

Transform transforms the passed ojbect to an array of strings

func (*TransformList) V

func (c *TransformList) V(v ...string) *TransformList

V provides the path to the value

type TransformMap

type TransformMap struct {
	Path  []string
	Key   []string
	Value []string
}

TransformMap transforms a JSON response to a mapper

func NewODTrans

func NewODTrans() *TransformMap

NewODTrans returns a transformation with the right path for offer decisionsing HAL responses

func NewTransformMap

func NewTransformMap(p ...string) *TransformMap

NewTransformMap creates an initialzed TransformMap object

func ODNameToID

func ODNameToID() *TransformMap

ODNameToID returns a transformation xdm:name -> @id

func ODNameToInstanceID

func ODNameToInstanceID() *TransformMap

ODNameToID returns a transformation xdm:name -> instanceId

func (*TransformMap) K

func (c *TransformMap) K(k ...string) *TransformMap

K provides the path to the key

func (*TransformMap) P

func (c *TransformMap) P(p ...string) *TransformMap

P provides the path to the rangable list inside the JSON file

func (TransformMap) Transform

func (c TransformMap) Transform(obj interface{}) util.Mapper

Transform transforms the passed ojbect to a mapper

func (*TransformMap) V

func (c *TransformMap) V(v ...string) *TransformMap

V provides the path to the value

Jump to

Keyboard shortcuts

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