mayfairserver

package module
v0.0.0-...-e44312a Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

README

mayfairserver

library for building apps for the distributed database middleware

Documentation

Overview

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

* * Frank Willem Mulder * __________________ * * Copyright 2026 Frank Willem Mulder. All rights reserved. * Use of this source code is governed license that can be found in the LICENSE file.

Index

Constants

View Source
const MaxMsgSize = 65536
View Source
const MqttBroker = "127.0.0.1"
View Source
const MqttPort = 1883
View Source
const SockLocalHost = "127.0.0.1"
View Source
const SockNetwork = "tcp"
View Source
const SockPort = 8677

Variables

This section is empty.

Functions

func DecodeMsg

func DecodeMsg(buf []byte) (uint16, []byte, []byte)

func EncodeMsg

func EncodeMsg(buf []byte) []byte

func Int16ToLen

func Int16ToLen(le uint16) []byte

func LenToInt16

func LenToInt16(buf []byte) uint16

func MsgString

func MsgString(buf []byte) string

func NewTlsConfig

func NewTlsConfig() *tls.Config

Types

type Client

type Client struct {
	StopCh chan bool
	ReadCh chan []byte
	// contains filtered or unexported fields
}

func NewClient

func NewClient(nwp Nwp, ps PubSubs, readCh chan []byte) Client

func (*Client) Get

func (c *Client) Get(tix int, ks ...any) (ot.FactI[any], bool)

func (*Client) GetN

func (c *Client) GetN(tix int, ks []any) (ot.FactI[any], bool)

func (*Client) GetReadCh

func (client *Client) GetReadCh() chan []byte

func (*Client) GetStopCh

func (client *Client) GetStopCh() chan bool

func (*Client) Name

func (c *Client) Name() string

func (*Client) Publish

func (c *Client) Publish(pubs ...string)

func (*Client) Query

func (c *Client) Query(tix int) []ot.FactI[any]

func (*Client) QueryN

func (c *Client) QueryN(tix int, ks []any) []ot.FactI[any]

func (*Client) Stop

func (c *Client) Stop(sendByClient bool)

func (*Client) Subscribe

func (c *Client) Subscribe(subs ...string)

type ClientI

type ClientI interface {
	Publish(pubs ...string)
	Subscribe(subs ...string)
	Listen(debug bool)
	Get(tix int, ks ...any) (ot.FactI[any], bool)
	GetN(tix int, ks []any) (ot.FactI[any], bool)
	Query(tix int) []ot.FactI[any]
	QueryN(tix int, ks []any) []ot.FactI[any]
	Put(f ot.FactI[any]) ot.TransactionType
	Stop(bool)
	Close()
	Name() string
	GetReadCh() chan []byte
	GetStopCh() chan bool
}

type ClientState

type ClientState int
const (
	INIT ClientState = iota
	RUNNING
	STOPPED
)

type Hartbeat

type Hartbeat struct {
	ot.Fact[any]
	Client  string    `json:"client"`
	Version int       `json:"version"`
	Stamp   time.Time `json:"time"`
}

Hartbeat is the main alive message sent by a client to the server

func NewHartbeat

func NewHartbeat(version int, client string) Hartbeat

func (Hartbeat) Keys

func (s Hartbeat) Keys() []any

func (Hartbeat) String

func (s Hartbeat) String() string

func (Hartbeat) ToBytes

func (s Hartbeat) ToBytes() []byte

type MayfairClient

type MayfairClient struct {
	Client
	// contains filtered or unexported fields
}

func NewMayfairClient

func NewMayfairClient(network string, host string, port int, ps PubSubs) *MayfairClient

func (*MayfairClient) Close

func (c *MayfairClient) Close()

Close closes all the connections and channes of a client when the stop msg has been received by the main client process

func (*MayfairClient) Listen

func (c *MayfairClient) Listen(debug bool)

Listen handles all incoming messages and outgoing messages from, to the mayfair db server

func (*MayfairClient) Put

type MayfairServer

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

func NewMayfairServer

func NewMayfairServer(network string, host string, port int) *MayfairServer

func (*MayfairServer) Listen

func (server *MayfairServer) Listen(debug bool)

Listen listens waits for connections made by clients and sets up the processing of the messages of a client through the connection

type MqttClient

type MqttClient struct {
	Client
	// contains filtered or unexported fields
}

func NewMqttClient

func NewMqttClient(network string, host string, port int, ps PubSubs) *MqttClient

func (*MqttClient) Close

func (c *MqttClient) Close()

Close closes all the connections and channes of a client when the stop msg has been received by the main client process

func (*MqttClient) Listen

func (c *MqttClient) Listen(debug bool)

Listen handles all incoming messages and outgoing messages from, to the mayfair db server

func (*MqttClient) Put

func (c *MqttClient) Put(f ot.FactI[any]) ot.TransactionType

type Nwp

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

func (Nwp) Host

func (p Nwp) Host() string

func (Nwp) String

func (p Nwp) String() string

type Ping

type Ping struct {
	ot.Fact[any]
	Id      int    `fact:"key"`
	Msg     string `json:"msg"`
	Version int    `json:"version"`
}

Ping is used for testing messages

func NewPing

func NewPing(msg string, id, vs int) Ping

func NewPong

func NewPong(msg string, id, vs int) Ping

func (Ping) Keys

func (p Ping) Keys() []any

func (Ping) String

func (p Ping) String() string

func (Ping) ToBytes

func (p Ping) ToBytes() []byte

type Pong

type Pong struct {
	ot.Fact[any]
	Id      int    `fact:"key"`
	Msg     string `json:"msg"`
	Version int    `json:"version"`
}

func (Pong) Keys

func (p Pong) Keys() []any

func (Pong) String

func (p Pong) String() string

func (Pong) ToBytes

func (p Pong) ToBytes() []byte

type PubSubs

type PubSubs struct {
	Name string   `json:"name"`
	Pubs []string `json:"pubs"`
	Subs []string `json:"subs"`
}

PubSubs is the publish/subscribe administration for a client

type Stop

type Stop struct {
	ot.Fact[any]
	Id           int    `fact:"key"`
	Client       string `json:"client"`
	SendByClient bool   `json:"send"`
}

Stop is the main stop message sent by a client to the server

func NewStop

func NewStop(client string, sendByClient bool) Stop

func (Stop) Keys

func (s Stop) Keys() []any

func (Stop) ToBytes

func (s Stop) ToBytes() []byte

Jump to

Keyboard shortcuts

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