repo

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HistoryRepoJSONPrefix = "contentserver-repo-"
	HistoryRepoJSONSuffix = ".json"
)

Variables

View Source
var (
	ErrUpdateRejected = errors.New("update rejected: queue full")
)

Functions

This section is empty.

Types

type Dimension

type Dimension struct {
	Directory    map[string]*content.RepoNode
	URIDirectory map[string]*content.RepoNode
	Node         *content.RepoNode
}

Dimension dimension in a repo

type History

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

func NewHistory

func NewHistory(l *zap.Logger, opts ...HistoryOption) *History

func (*History) Add

func (h *History) Add(jsonBytes []byte) error

func (*History) GetCurrent

func (h *History) GetCurrent(buf *bytes.Buffer) error

func (*History) GetCurrentFilename

func (h *History) GetCurrentFilename() string

type HistoryOption

type HistoryOption func(*History)

func HistoryWithHistoryDir

func HistoryWithHistoryDir(v string) HistoryOption

func HistoryWithHistoryLimit

func HistoryWithHistoryLimit(v int) HistoryOption

type Option

type Option func(*Repo)

Repo content repository

func WithHTTPClient

func WithHTTPClient(v *http.Client) Option

func WithPoll

func WithPoll(v bool) Option

func WithPollInterval

func WithPollInterval(v time.Duration) Option

type Repo

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

Repo content repository

func New

func New(l *zap.Logger, url string, history *History, opts ...Option) *Repo

func (*Repo) DimensionUpdateRoutine

func (r *Repo) DimensionUpdateRoutine(ctx context.Context) error

func (*Repo) Directory

func (r *Repo) Directory() map[string]*Dimension

func (*Repo) GetContent

func (r *Repo) GetContent(req *requests.Content) (*content.SiteContent, error)

GetContent resolves content and fetches nodes in one call. It combines those two tasks for performance reasons.

In the first step it uses r.URI to look up content in all given r.Env.Dimensions of repo.Directory.

In the second step it collects the requested nodes.

those two steps are independent.

func (*Repo) GetNodes

func (r *Repo) GetNodes(nodes *requests.Nodes) map[string]*content.Node

GetNodes get nodes

func (*Repo) GetRepo

func (r *Repo) GetRepo() map[string]*content.RepoNode

GetRepo get the whole repo in all dimensions

func (*Repo) GetURIs

func (r *Repo) GetURIs(dimension string, ids []string) map[string]string

GetURIs get many uris at once

func (*Repo) JSONBufferBytes

func (r *Repo) JSONBufferBytes() []byte

func (*Repo) Loaded

func (r *Repo) Loaded() bool

func (*Repo) OnLoaded

func (r *Repo) OnLoaded(fn func())

func (*Repo) PollRoutine

func (r *Repo) PollRoutine(ctx context.Context) error

func (*Repo) SetDirectory

func (r *Repo) SetDirectory(v map[string]*Dimension)

func (*Repo) SetJSONBuffer

func (r *Repo) SetJSONBuffer(v *bytes.Buffer)

func (*Repo) Start

func (r *Repo) Start(ctx context.Context) error

func (*Repo) Update

func (r *Repo) Update() (updateResponse *responses.Update)

func (*Repo) UpdateRoutine

func (r *Repo) UpdateRoutine(ctx context.Context) error

func (*Repo) WriteRepoBytes

func (r *Repo) WriteRepoBytes(w io.Writer)

WriteRepoBytes get the whole repo in all dimensions reads the JSON history file from the Filesystem and copies it directly in to the supplied buffer the result is wrapped as service response, e.g: {"reply": <contentData>}

type RepoDimension

type RepoDimension struct {
	Dimension string
	Node      *content.RepoNode
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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