zap

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package zap adds the HIP-0110 ZAP server surface to Hanzo Base.

Base already speaks ZAP via plugins/zap (Collections=100, Records=101, Auth=102, Realtime=103). HIP-0110 adds upper-half handlers that share the same socket:

MsgTypeForward (0x1010)   — gateway → base request. Decoded and
                            delegated to a pluggable Dispatcher.
MsgTypeSubscribe (0x1030) — gateway → base subscription registration.
                            Future record changes for the collection
                            produce MsgTypePush envelopes routed to
                            the right gateway peer.

No new pubsub; reuses base's realtime subscription pattern.

Index

Constants

View Source
const (
	MsgTypeForward   uint16 = 0x80
	MsgTypePush      uint16 = 0x81
	MsgTypeSubscribe uint16 = 0x82
)

HIP-0110 message-type IDs. Mirror github.com/hanzoai/gateway/zap_wire.go. zap.FinishWithFlags expects the type in the upper byte of a uint16 (`type << 8`), so types must fit in uint8. Picked in the 0x80+ range so they don't collide with base/plugins/zap's lower-byte IDs (Collections=100, Records=101, Auth=102, Realtime=103).

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, f Forward) (status uint32, headers, body []byte, err error)
}

Dispatcher routes a Forward envelope to a matching base handler.

type Forward

type Forward struct {
	TenantID, UserID     string
	IsAdmin              bool
	Permissions          int64
	Method, Path, ConnID string
	Headers, Body        []byte
}

Forward is the parsed envelope handed to the per-path dispatcher.

type Server

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

Server adds the HIP-0110 surface to a base instance.

func NewServer

func NewServer(logger luxlog.Logger, node *zaplib.Node, d Dispatcher) (*Server, error)

NewServer constructs the HIP-0110 add-on. `node` is reused from base's plugins/zap so legacy and HIP-0110 IDs share one socket.

func (*Server) BroadcastRecord

func (s *Server) BroadcastRecord(ctx context.Context, collection string, frame []byte, encoding string)

BroadcastRecord pushes a pre-encoded SSE / WS frame to every gateway holding a conn subscribed to `collection`. Base does NOT re-marshal JSON for the push path.

func (*Server) Register

func (s *Server) Register()

Register installs the HIP-0110 handlers. Call once during base startup, after plugins/zap has registered its lower-half IDs.

Jump to

Keyboard shortcuts

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