graphify

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Unlicense Imports: 38 Imported by: 1

README

graphify

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminFromContext added in v0.0.11

func AdminFromContext(ctx context.Context) (value *adminv1.Admin, found bool)

AdminFromContext ...

func ContextWithAdmin added in v0.0.11

func ContextWithAdmin(parent context.Context, admin *adminv1.Admin) context.Context

ContextWithAdmin ...

func DevelopmentContext added in v0.0.12

func DevelopmentContext(parent context.Context) context.Context

DevelopmentContext ...

func ExposeNodes added in v0.4.3

func ExposeNodes(nodes ...any) exposedNodes

ExposeNodes ...

func IsDevelopmentContext added in v0.0.12

func IsDevelopmentContext(ctx context.Context) (value bool)

IsDevelopmentContext ...

func Mutation added in v0.1.0

func Mutation[Arg interfaces.GraphqlArgument, Out interfaces.GraphqlOutput](fn func(context.Context, Arg) (Out, error)) mutation

Mutation ...

func NewConnection

func NewConnection(ctx context.Context, conf ConnectionConfig) *connection

NewConnection ...

func NewFilesystemStorage added in v0.0.6

func NewFilesystemStorage(params FilesystemStorageConfig) *filesystemStorage

NewFilesystemStorage ...

func Query added in v0.1.0

func Query[Arg interfaces.GraphqlArgument, Out interfaces.GraphqlOutput](fn func(context.Context, Arg) (Out, error)) query

Query ...

Types

type AdminHandler added in v0.4.3

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

AdminHandler ...

func NewAdminHandler added in v0.4.3

func NewAdminHandler(ctx context.Context, config AdminHandlerConfig, params AdminHandlerParams) *AdminHandler

NewAdminHandler ...

func (*AdminHandler) Handler added in v0.4.3

func (e *AdminHandler) Handler(ctx context.Context) http.Handler

Handler ...

type AdminHandlerConfig added in v0.4.3

type AdminHandlerConfig struct {
	Secret []byte
}

AdminHandlerConfig ...

type AdminHandlerParams added in v0.4.3

type AdminHandlerParams struct {
	fx.In

	Access   IAccess
	Graph    IGraph
	Storage  IFileStorage
	Observer IObserver[Topic]
}

AdminHandlerParams ...

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 ArangoAccess added in v0.4.3

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

func NewArangoAccess added in v0.4.3

func NewArangoAccess(conn IConnection, observer IObserver[Topic]) *ArangoAccess

func (*ArangoAccess) AutoMigrate added in v0.4.3

func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph IGraph) error

AutoMigrate ...

func (*ArangoAccess) Collection added in v0.4.3

func (e *ArangoAccess) Collection(ctx context.Context, elem any, callbacks ...CollectionCallback) (err error)

Collection ...

func (*ArangoAccess) Create added in v0.4.3

func (e *ArangoAccess) Create(ctx context.Context, val any) ([]string, error)

Create ...

func (*ArangoAccess) Delete added in v0.4.3

func (e *ArangoAccess) Delete(ctx context.Context, item any) error

Delete ...

func (*ArangoAccess) Find added in v0.4.3

func (e *ArangoAccess) Find(ctx context.Context, bindVars Vars, out any) error

Find ...

func (*ArangoAccess) List added in v0.4.3

func (e *ArangoAccess) List(ctx context.Context, bindVars Vars, out any) (int64, error)

List ...

func (*ArangoAccess) ListKeys added in v0.4.3

func (e *ArangoAccess) ListKeys(ctx context.Context, keys []string, out any) error

ListKeys ...

func (*ArangoAccess) Read added in v0.4.3

func (e *ArangoAccess) Read(ctx context.Context, key string, out any) error

Read ...

func (*ArangoAccess) Relations added in v0.4.3

func (e *ArangoAccess) Relations(ctx context.Context, id string, bindVars Vars, direction Direction, out any) (int, error)

Relations ...

func (*ArangoAccess) Replace added in v0.4.3

func (e *ArangoAccess) Replace(ctx context.Context, key string, item any) error

Replace ...

func (*ArangoAccess) Update added in v0.4.3

func (e *ArangoAccess) Update(ctx context.Context, key string, item any) error

Update ...

type CollectionCallback added in v0.4.3

type CollectionCallback func(context.Context, driver.Collection)

CollectionCallback ...

type ConnectionConfig added in v0.4.3

type ConnectionConfig struct {
	// DBName ...
	DBName string
	// UserName ...
	UserName string
	// Password ...
	Password string
	// Connection ...
	Connection http.ConnectionConfig
}

ConnectionConfig ...

type Direction added in v0.0.12

type Direction string
const (
	DirectionInbound  Direction = "INBOUND"
	DirectionOutbound Direction = "OUTBOUND"
	DirectionAny      Direction = "ANY"
)

type Empty added in v0.4.3

type Empty struct{}

Empty is ignored from graphql input

func (*Empty) Argument added in v0.4.3

func (*Empty) Argument() graphql.FieldConfigArgument

type Event

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

Event ...

type FilesystemStorageConfig added in v0.4.3

type FilesystemStorageConfig struct {
	// BasePath ...
	BasePath string
	// MaxMemory ...
	MaxMemory int
}

FilesystemStorageConfig ...

type Graph added in v0.4.3

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

Graph ...

func NewGraph

func NewGraph() *Graph

NewGraph ...

func (*Graph) CollectionFor added in v0.4.3

func (g *Graph) CollectionFor(t reflect.Type) string

CollectionFor ...

func (*Graph) Edge added in v0.4.3

func (g *Graph) Edge(from, to, edge any)

Edge ...

func (*Graph) Edges added in v0.4.3

func (g *Graph) Edges() []reflect.Type

Edges ...

func (*Graph) Node added in v0.4.3

func (g *Graph) Node(node any)

Node ...

func (*Graph) Nodes added in v0.4.3

func (g *Graph) Nodes() []reflect.Type

Nodes ...

func (*Graph) Relation added in v0.4.3

func (g *Graph) Relation(edge reflect.Type) *Relation

Relation ...

func (*Graph) TypeOf added in v0.4.3

func (g *Graph) TypeOf(collection string) reflect.Type

TypeOf ...

type GraphqlHandler added in v0.4.3

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

GraphqlHandler ...

func NewGraphqlHandler added in v0.4.3

func NewGraphqlHandler(access IAccess, graph IGraph) *GraphqlHandler

NewGraphqlHandler ...

func (*GraphqlHandler) Handler added in v0.4.3

func (e *GraphqlHandler) Handler(ctx context.Context, handlers ...interface{}) *handler.Handler

Handler ...

type IAccess added in v0.4.3

type IAccess interface {
	// AutoMigrate ...
	AutoMigrate(ctx context.Context, graph IGraph) error

	// Collection ...
	Collection(ctx context.Context, elem any, callbacks ...CollectionCallback) (err error)

	// List ...
	List(ctx context.Context, bindVars Vars, out any) (int64, error)

	// ListKeys ...
	ListKeys(ctx context.Context, keys []string, out any) error

	// Find ...
	Find(ctx context.Context, bindVars Vars, out any) error

	// Read ...
	Read(ctx context.Context, key string, out any) error

	// Create ...
	Create(ctx context.Context, val any) ([]string, error)

	// Update ...
	Update(ctx context.Context, key string, item any) error

	// Replace ...
	Replace(ctx context.Context, key string, item any) error

	// Delete ...
	Delete(ctx context.Context, item any) error

	// Relations ...
	Relations(ctx context.Context, id string, bindVars Vars, direction Direction, out any) (int, error)
}

IAccess ...

type IConnection

type IConnection interface {
	// Database ...
	Database(ctx context.Context) (driver.Database, error)
	// Collection ...
	Collection(ctx context.Context, elem any) (driver.Collection, error)
	// Reflect ...
	Reflect(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 []byte) (hash string, err error)

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

	// MaxMemory ...
	MaxMemory() int
}

IFileStorage ...

type IGraph added in v0.4.3

type IGraph interface {
	// Node ...
	Node(node any)
	// Edge ...
	Edge(from, to, edge any)

	// Nodes ...
	Nodes() []reflect.Type
	// Edges ...
	Edges() []reflect.Type
	// Relation ...
	Relation(edge reflect.Type) *Relation

	// CollectionFor ...
	CollectionFor(elem reflect.Type) string
	// TypeOf ...
	TypeOf(colection string) reflect.Type
}

IGraph ...

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 PaginationResult added in v0.1.14

type PaginationResult struct {
	Items any   `json:"items"`
	Count int64 `json:"count"`
}

type Processor

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

Processor ...

type Relation added in v0.4.3

type Relation struct {
	From reflect.Type `json:"_from"`
	To   reflect.Type `json:"_to"`
}

Relation

type SourceID

type SourceID int64

SourceID ...

type Topic

type Topic string
var (
	CreatedTopic  Topic = "created"
	UpdatedTopic  Topic = "updated"
	ReplacedTopic Topic = "replaced"
	DeletedTopic  Topic = "deleted"
)
var (
	AdminCreatedTopic  Topic = "admin_created"
	AdminReplacedTopic Topic = "admin_replaced"
	AdminDeletedTopic  Topic = "admin_deleted"
)

func (Topic) For added in v0.0.2

func (t Topic) For(elem any) Topic

type Vars added in v0.4.3

type Vars map[string]interface{}

Jump to

Keyboard shortcuts

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