sqlite

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DemoResourceUnmarshal

type DemoResourceUnmarshal struct{}

func (DemoResourceUnmarshal) UnmarshalResource

func (d DemoResourceUnmarshal) UnmarshalResource(_ resource.Type, resourceData string) (resource.Resource, error)

UnmarshalResource implements ResourceUnmarshaler. The reason this has to be split for demo resources is that the demo resources can take on any type. Eg: a demo resource can be a scaleway.Project, a scaleway.Container, a scaleway.Function, etc.

type ResourceUnmarshaler

type ResourceUnmarshaler interface {
	// UnmarshalResource unmarshals a resource from a string.
	UnmarshalResource(resourceType resource.Type, resourceData string) (resource.Resource, error)
}

type ScalewayResourceUnmarshal

type ScalewayResourceUnmarshal struct{}

func (ScalewayResourceUnmarshal) UnmarshalResource

func (s ScalewayResourceUnmarshal) UnmarshalResource(resourceType resource.Type, resourceData string) (resource.Resource, error)

UnmarshalResource implements ResourceUnmarshaler.

type Store

type Store struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

func NewStore

func NewStore(ctx context.Context, shard string) (*Store, error)

NewStore creates a new store. The store is used to save the resources in a database, to avoid querying the API every time. It also allows doing some analysis on the resources, like finding dangling resources.

func (*Store) Close

func (s *Store) Close() error

Close closes the store.

func (*Store) DeleteResource

func (s *Store) DeleteResource(ctx context.Context, r resource.Resource) error

DeleteResource implements resource.Storer.

func (*Store) GetResource

func (s *Store) GetResource(ctx context.Context, resourceID string) (resource.Resource, error)

GetResource implements resource.Storer.

func (*Store) ListAllResources

func (s *Store) ListAllResources(ctx context.Context) ([]resource.Resource, error)

ListAllResources implements resource.Storer.

func (*Store) SetUnmarshaller

func (s *Store) SetUnmarshaller(u ResourceUnmarshaler)

SetUnmarshaller sets the unmarshaller used to unmarshal the resources. In demo mode, the unmarshaller is set to a demo unmarshaller that returns a demo resource.

func (*Store) Store

func (s *Store) Store(ctx context.Context, r resource.Resource) error

Store implements resource.Storer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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