graphify

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: Unlicense Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectionFor

func CollectionFor(t reflect.Type) string

CollectionFor ...

func ContextWithDatabaseConfig

func ContextWithDatabaseConfig(ctx context.Context, cnf DatabaseConfig) context.Context

ContextWithDatabaseConfig ...

func Create

func Create(ctx context.Context, val interface{}, comm *Common) ([]string, error)

Create ...

func Delete

func Delete(ctx context.Context, item interface{}, comm *Common) error

Delete ...

func List

func List(ctx context.Context, offset, count int, out interface{}, comm *Common) (int, error)

List ...

func ListKeys

func ListKeys(ctx context.Context, keys []string, out interface{}, comm *Common) error

ListKeys ...

func NewConnection

func NewConnection(username, password string) *connection

NewConnection ...

func NewFilesystemStorage added in v0.0.6

func NewFilesystemStorage(basePath string, maxMemory int64) *filesystemStorage

NewFilesystemStorage ...

func NewGraph

func NewGraph(comm *Common) *graph

func Read

func Read(ctx context.Context, key string, out interface{}, comm *Common) error

Read ...

func Update

func Update(ctx context.Context, key string, item interface{}, comm *Common) error

Update ...

func WriteErrorResponse

func WriteErrorResponse(w http.ResponseWriter, status int, err error)

func WriteFileResponse added in v0.0.6

func WriteFileResponse(w http.ResponseWriter, filename, fileContentType string, fileContent []byte)

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, status int, data interface{})

func WriteResponse added in v0.0.2

func WriteResponse(w http.ResponseWriter, status int, data []byte)

Utils

func WriteSuccessResponse

func WriteSuccessResponse(w http.ResponseWriter, status int)

Types

type ApplicationConfig added in v0.0.9

type ApplicationConfig struct {
	// Name ...
	Name string `json:"name"`
	// Domain ...
	Domain string `json:"domain"`
	Logo string `json:"logo"`
}

ApplicationConfig ...

type ApplicationConfigInit added in v0.0.9

type ApplicationConfigInit struct {
	// Config ...
	Config ApplicationConfig `json:"config"`
	// Admin ...
	Admin adminv1.Admin `json:"admin"`
	// Password ...
	Password string `json:"password"`
}

ApplicationConfigInit ...

type Common

type Common struct {
	Observer   IObserver[Topic]
	Connection IConnection
	Storage    IFileStorage
}

type DatabaseConfig

type DatabaseConfig struct {
	// Name ...
	Name string
}

DatabaseConfig ...

func DatabaseConfigFromContext

func DatabaseConfigFromContext(ctx context.Context) (*DatabaseConfig, error)

DatabaseConfigFromContext ...

type Event

type Event[T comparable] struct {
	// Topic ...
	Topic T
	// Payload ...
	Payload protoreflect.ProtoMessage
	// Timestamp ...
	Timestamp time.Time
}

Event ...

type IConnection

type IConnection interface {
	// GetDatabase ...
	GetDatabase(ctx context.Context) (driver.Database, error)
	// GetCollection ...
	GetCollection(ctx context.Context, elem reflect.Type) (driver.Collection, error)
}

IConnection ...

type IFileStorage added in v0.0.6

type IFileStorage interface {
	// StoreFile ...
	StoreFile(name string, file []byte) (err error)

	// StoreByHash ...
	StoreByHash(file multipart.File) (hash string, err error)

	// ReadFile ...
	ReadFile(name string) (fileContent []byte, errr error)

	// MaxMemory ...
	MaxMemory() int64
}

IFileStorage ...

type IObserver

type IObserver[T comparable] interface {
	// Subscribe ...
	Subscribe(t T, p Processor[T]) SourceID
	// Unsubscribe ...
	Unsubscribe(s SourceID)
	// Emit ...
	Emit(e *Event[T]) error
}

IObserver ...

type Observer

type Observer[T comparable] struct {
	// contains filtered or unexported fields
}

Observer ...

func NewObserver

func NewObserver[T comparable]() *Observer[T]

NewObserver ...

func (*Observer[T]) Emit

func (o *Observer[T]) Emit(e *Event[T]) error

Emit ...

func (*Observer[T]) Subscribe

func (o *Observer[T]) Subscribe(t T, p Processor[T]) SourceID

Subscribe ...

func (*Observer[T]) Unsubscribe

func (o *Observer[T]) Unsubscribe(s SourceID)

Unsubscribe ...

type Processor

type Processor[T comparable] func(e *Event[T]) error

Processor ...

type SourceID

type SourceID int64

SourceID ...

type Topic

type Topic string
var (
	CreatedTopic Topic = "created"
	UpdatedTopic Topic = "updated"
	DeletedTopic Topic = "deleted"
)

func (Topic) For added in v0.0.2

func (t Topic) For(elem interface{}) Topic

Directories

Path Synopsis
models

Jump to

Keyboard shortcuts

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