nex

package
v0.0.0-...-cd58e7a Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 15 Imported by: 4

README

Nex

The Hypernet.Nexus development SDK. Defined the useful functions and ways to handle data for both server side and client.

Parts

Nex.Cruda

Create Read Update Delete Accelerator, aka. Cruda. Cruda will help you to build a simplified database access layer based on the command system in nexus.

Nex.Sec

The security part of nexus, including signing and validating the tokens and much more.

Nex.Rx

The reactive part of nexus, such as streaming events, and message queues stuff.

Documentation

Index

Constants

View Source
const (
	AllocatableResourceMq = AllocatableResourceType("mq")
	AllocatableResourceKv = AllocatableResourceType("kv")
)
View Source
const (
	ServiceTypeAuth   = "id"
	ServiceTypePusher = "pusher"
)

Variables

This section is empty.

Functions

func CtxValueMustBe

func CtxValueMustBe[T any](c *CommandCtx, key string) (T, error)

func CtxValueShouldBe

func CtxValueShouldBe[T any](c *CommandCtx, key string, defaultValue T) T

func DecodeMap

func DecodeMap(raw []byte) map[string]any

func EncodeMap

func EncodeMap(data any) []byte

func GetCommandKey

func GetCommandKey(id, method string) string

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Types

type AllocatableResourceType

type AllocatableResourceType = string

type CommandCtx

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

func (*CommandCtx) JSON

func (c *CommandCtx) JSON(data any, statusCode ...int) error

func (*CommandCtx) Read

func (c *CommandCtx) Read() []byte

func (*CommandCtx) ReadJSON

func (c *CommandCtx) ReadJSON(out any) error

func (*CommandCtx) Value

func (c *CommandCtx) Value(key string, newValue ...any) any

func (*CommandCtx) ValueOrElse

func (c *CommandCtx) ValueOrElse(key string, defaultValue any) any

func (*CommandCtx) Values

func (c *CommandCtx) Values() map[string]any

func (*CommandCtx) Write

func (c *CommandCtx) Write(data []byte, contentType string, statusCode ...int) error

type CommandHandler

type CommandHandler func(ctx *CommandCtx) error

type Conn

type Conn struct {
	Addr string
	Info *proto.ServiceInfo
	// contains filtered or unexported fields
}

func NewNexusConn

func NewNexusConn(addr string, info *proto.ServiceInfo) (*Conn, error)

func (*Conn) AddCommand

func (v *Conn) AddCommand(id, method string, tags []string, fn CommandHandler) error

func (*Conn) AllocResource

func (v *Conn) AllocResource(t AllocatableResourceType) any

func (*Conn) GetClientGrpcConn

func (v *Conn) GetClientGrpcConn(t string) (*grpc.ClientConn, error)

func (*Conn) GetNexusGrpcConn

func (v *Conn) GetNexusGrpcConn() *grpc.ClientConn

func (*Conn) RegisterService

func (v *Conn) RegisterService() error

func (*Conn) RunCommands

func (v *Conn) RunCommands(addr string) error

func (*Conn) RunRegistering

func (v *Conn) RunRegistering() error

type WebSocketPackage

type WebSocketPackage struct {
	Action   string `json:"w"`
	Endpoint string `json:"e,omitempty"`
	Message  string `json:"m,omitempty"`
	Payload  any    `json:"p"`
}

func (WebSocketPackage) Marshal

func (v WebSocketPackage) Marshal() []byte

func (WebSocketPackage) RawPayload

func (v WebSocketPackage) RawPayload() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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