service

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

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

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndPointFromCacheService

func EndPointFromCacheService(s CacheService) endpoint.Endpoint

Types

type CacheKey

type CacheKey struct {
	Schema   models.Schema
	Contents string
}

Composite key used by Cache to uniquely identify a render result

func (CacheKey) Hash

func (k CacheKey) Hash() string

Returns base64 endcoded sha256 sum of key.Schema + k.Contents

type CacheService

type CacheService interface {
	// On success returns the render result from the cache at input key, returns error != nil if failed
	Get(CacheKey) (string, error)
	// Maps input key to input render result inside the cache, returns error != nil if failed
	Set(CacheKey, string) error
}

Stores render results, which can be set/retrieved via a CacheKey

func CacheServiceFromEndpoint

func CacheServiceFromEndpoint(ctx context.Context, e endpoint.Endpoint) CacheService

type RenderService

type RenderService interface {
	// Uses html/template to render the input context with the given schema, writes result to input writer
	//
	// Returns error != nil if failed
	Render(string, models.Schema, io.Writer) error
}

func NewRenderService

func NewRenderService(cache CacheService) RenderService

Returns default implementation of a RenderService, using a cache.

type RenderServiceMiddleware

type RenderServiceMiddleware func(RenderService) RenderService

Chainable behavior modifier for RenderService.

Jump to

Keyboard shortcuts

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