api

package
v0.0.0-...-4d6a655 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(ctx context.Context, redisAddr string, db database.Database, logger *zap.Logger, opts ...CacheOption) (*itemCache, error)

NewCache creates a new cache

func NewServer

func NewServer(port int, logger *zap.Logger, srv pb.APIServer) *server

NewServer creates a new server

Types

type Cache

type Cache interface {
	GetAll(ctx context.Context) ([]models.Item, error)
	GetStories(ctx context.Context) ([]models.Item, error)
	GetJobs(ctx context.Context) ([]models.Item, error)
}

Cache is an interace to expose cache methods

type CacheOption

type CacheOption func(c *itemCache)

CacheOption is an interface for a functional option

func WithTTL

func WithTTL(ttl time.Duration) CacheOption

WithTTL is a functional option to configure the cache TTL

type Handler

type Handler struct {
	pb.UnimplementedAPIServer
	Cache Cache
}

Handler contains the endpoint handlers

func (Handler) ListAll

func (h Handler) ListAll(empty *emptypb.Empty, s pb.API_ListAllServer) error

ListAll streams a collection of items to a client

func (Handler) ListJobs

func (h Handler) ListJobs(empty *emptypb.Empty, s pb.API_ListJobsServer) error

ListJobs streams a collection of job items to a client

func (Handler) ListStories

func (h Handler) ListStories(empty *emptypb.Empty, s pb.API_ListStoriesServer) error

ListStories streams a collection of story items to a client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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