toy

package
v0.0.0-...-0071f02 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BucketName string
	Port       int
}

Config holds the static config our server needs

func (*Config) Flags

func (c *Config) Flags() []cli.Flag

Flags returns a slice of urfave.Flag to allow our configuration to be populated by flags or env vars

type LocalStore

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

LocalStore is an in-memory implementation of our store interface

func NewLocalStore

func NewLocalStore() *LocalStore

NewLocalStore returns a local implementation of the Store interface

func (*LocalStore) Del

func (l *LocalStore) Del(ctx context.Context, key string) error

Del removes the data stored at the given key

func (*LocalStore) Get

func (l *LocalStore) Get(ctx context.Context, key string) (string, error)

Get retrieves the data stored at the given key

func (*LocalStore) Set

func (l *LocalStore) Set(ctx context.Context, key, data string) error

Set stores the given data at the given key

type Server

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

Server represents all of the config and clients needed to run our app

func New

func New(c *Config, s Store) *Server

New tries to cerate a new instance of Service

func (*Server) Router

func (s *Server) Router() *chi.Mux

Router exposes our chi Route externally

func (*Server) Start

func (s *Server) Start()

Start starts the server

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server gracefully

type Store

type Store interface {
	Get(context.Context, string) (string, error) // HL
	Set(context.Context, string, string) error   // HL
	Del(context.Context, string) error           // HL
}

Store provides an interface to the blobs we store in the toy app

Jump to

Keyboard shortcuts

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