services

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePDFRenderService

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

BasePDFRenderService base implementation of PDFRenderService.

func NewBasePDFRenderService

func NewBasePDFRenderService(
	store templates.Store,
	tracerProvider trace.TracerProvider,
) *BasePDFRenderService

NewBasePDFRenderService constructor.

func (*BasePDFRenderService) GetExamplesData added in v0.9.0

func (pdfRender *BasePDFRenderService) GetExamplesData(
	_ context.Context,
	templateName string,
) (map[string]Data, error)

GetExamplesData return examples data for template.

func (*BasePDFRenderService) PreviewRenderPlan added in v0.11.3

func (pdfRender *BasePDFRenderService) PreviewRenderPlan(
	ctx context.Context,
	templateName string,
	data Data,
) ([]templates.RenderTask, error)

PreviewRenderPlan find template by name and build render plan.

func (*BasePDFRenderService) RenderPDFExample

func (pdfRender *BasePDFRenderService) RenderPDFExample(
	ctx context.Context,
	templateName string,
	exampleName string,
) ([]byte, error)

RenderPDFExample find template and example by name and render it to PDF.

func (*BasePDFRenderService) RenderPDFWithData

func (pdfRender *BasePDFRenderService) RenderPDFWithData(
	ctx context.Context,
	templateName string,
	data Data,
) ([]byte, error)

RenderPDFWithData find template by name and render it to PDF.

type Data

type Data = templates.Data

Data for render HTML.

type DataValidationError

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

DataValidationError returned by services when template return data validation error.

func NewDataValidationError

func NewDataValidationError(err error) *DataValidationError

NewDataValidationError construct new DataValidationError.

func (*DataValidationError) Error

func (err *DataValidationError) Error() string

func (*DataValidationError) Is added in v0.9.1

func (err *DataValidationError) Is(otherErr error) bool

Is cast error type and match inner errors.

func (*DataValidationError) Unwrap

func (err *DataValidationError) Unwrap() error

Unwrap inner error.

type DirectStatsService

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

DirectStatsService return service stats.

func NewDirectStatsService

func NewDirectStatsService(
	renderer pdfrender.PDFRenderer,
) *DirectStatsService

NewDirectStatsService constructor.

func (*DirectStatsService) Stats

func (service *DirectStatsService) Stats(ctx context.Context) (*Stats, error)

Stats collect service stats.

type ExampleNotFoundError

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

ExampleNotFoundError wrap templates error.

func NewExampleNotFoundError

func NewExampleNotFoundError(exampleName string) *ExampleNotFoundError

NewExampleNotFoundError construct new ExampleNotFoundError.

func (*ExampleNotFoundError) Error

func (err *ExampleNotFoundError) Error() string

func (*ExampleNotFoundError) Is

func (err *ExampleNotFoundError) Is(otherErr error) bool

Is change error type and call errors.Is on inner error.

type ExampleSpec

type ExampleSpec struct {
	Name string
}

ExampleSpec for building API specification.

type JSONSchema

type JSONSchema interface {
	MarshalJSON() ([]byte, error)
}

JSONSchema define marshalable JSON schema instance.

type NotCompositeTemplateError added in v0.11.3

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

NotCompositeTemplateError returned when template is not composite.

func NewNotCompositeTemplateError added in v0.11.3

func NewNotCompositeTemplateError(templateName string) *NotCompositeTemplateError

NewNotCompositeTemplateError construct new NotCompositeTemplateError.

func (*NotCompositeTemplateError) Error added in v0.11.3

func (err *NotCompositeTemplateError) Error() string

Error return error message.

func (*NotCompositeTemplateError) Is added in v0.11.3

func (err *NotCompositeTemplateError) Is(otherErr error) bool

Is return true if otherErr is NotCompositeTemplateError and templateName is equal.

type PDFRenderService

type PDFRenderService interface {
	RenderPDFWithData(
		ctx context.Context,
		templateName string,
		data Data,
	) ([]byte, error)
	RenderPDFExample(
		ctx context.Context,
		templateName string,
		exampleName string,
	) ([]byte, error)
	PreviewRenderPlan(
		ctx context.Context,
		templateName string,
		data Data,
	) ([]templates.RenderTask, error)
	GetExamplesData(
		ctx context.Context,
		templateName string,
	) (map[string]Data, error)
}

PDFRenderService interface describe service when render PDF by template name and data.

type RenderInfo

type RenderInfo struct {
	Pool     RenderPoolInfo
	Metadata map[string]string
}

RenderInfo contains pool info and metadata.

type RenderPoolInfo

type RenderPoolInfo struct {
	Stats RenderPoolStats
	Type  string
}

RenderPoolInfo contains pool stats and type.

type RenderPoolStats

type RenderPoolStats struct {
	Active      int
	Idle        int
	Destroyed   int
	Invalidated int
}

RenderPoolStats container internal render pool stats.

type SimpleValidateService

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

SimpleValidateService parse templates and render all examples.

func NewSimpleValidateService

func NewSimpleValidateService(
	templatesStore templates.Store,
) *SimpleValidateService

NewSimpleValidateService constructor.

func (*SimpleValidateService) Validate

func (validateService *SimpleValidateService) Validate(
	ctx context.Context,
	filter []string,
) error

Validate iterate over all templates and render all examples. Return false if any render of example return error.

type SpecService

type SpecService interface {
	GetSpec() ([]TemplateSpec, error)
	GetTemplateSchema(templateName string) (JSONSchema, error)
}

SpecService build internal representation of API specification.

type Stats

type Stats struct {
	RenderInfo RenderInfo
}

Stats of service.

type StatsService

type StatsService interface {
	Stats(context.Context) (*Stats, error)
}

StatsService collect service stats.

type TemplateNotFoundError

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

TemplateNotFoundError wrap templates.TemplateNotExistsError.

func NewTemplateNotFound

func NewTemplateNotFound(err error) *TemplateNotFoundError

NewTemplateNotFound construct new TemplateNotFoundError.

func (*TemplateNotFoundError) Error

func (err *TemplateNotFoundError) Error() string

func (*TemplateNotFoundError) Is

func (err *TemplateNotFoundError) Is(otherErr error) bool

Is cast error type and match inner errors.

func (*TemplateNotFoundError) Unwrap

func (err *TemplateNotFoundError) Unwrap() error

Unwrap inner error.

type TemplateSpec

type TemplateSpec struct {
	Name        string
	Schema      JSONSchema
	Examples    []ExampleSpec
	IsComposite bool
}

TemplateSpec for building API specification.

type TemplateSpecService

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

TemplateSpecService build API spec from templates.Store.

func NewTemplateSpecService

func NewTemplateSpecService(templatesStore templates.Store) *TemplateSpecService

NewTemplateSpecService construct TemplateSpecService instance.

func (*TemplateSpecService) GetSpec

func (service *TemplateSpecService) GetSpec() ([]TemplateSpec, error)

GetSpec return API specification from templates.Store.

func (*TemplateSpecService) GetTemplateSchema

func (service *TemplateSpecService) GetTemplateSchema(templateName string) (JSONSchema, error)

GetTemplateSchema return template spec from templates.Store.

type ValidateService

type ValidateService interface {
	Validate(
		ctx context.Context,
		filter []string,
	) error
}

ValidateService interface.

Jump to

Keyboard shortcuts

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