resutil

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package resutil provides RES utility functions, complementing the more common ones in the github.com/jirenius/go-res package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNATSMessageHandler

func AddNATSMessageHandler(
	service *res.Service,
	subject string,
	handler func(message *nats.Msg) error,
) error

AddNATSMessageHandler to a RES service. The handler will be called for each message received on the given subject.

func CompareModels added in v0.0.48

func CompareModels[T any](previous, current T) map[string]any

CompareModels and returns a map of the differences between them. The result can be used with the https://pkg.go.dev/github.com/jirenius/go-res#Request.ChangeEvent method.

func HandleCollectionQueryRequest

func HandleCollectionQueryRequest[T any](
	service *res.Service,
	rid string,
	handler func(request res.QueryRequest) ([]T, error),
) error

func HandleModelQueryRequest

func HandleModelQueryRequest[T any](
	service *res.Service,
	rid string,
	handler func(request res.QueryRequest) (T, error),
) error

func MapRefs

func MapRefs[E any, S []E](s S, f func(e E) res.Ref) []res.Ref

MapRefs from a slice of elements. The function f is called for each element in the slice, and the resulting reference is added to the result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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