server

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Plugin = plugins.Plugin{
	Inject: New,
	Resolve: func(r web.RouterPool, c *AppV1, ws ws.WebsocketServer) {
		router := r.Main()

		c.SetBroadcastHandler(ws.SendEvent)

		ws.SetHandler(c.ProxyWS(c.KVGetV1), api.EventKVGet)
		ws.SetHandler(c.ProxyWS(c.KVSetV1), api.EventKVSet)
		ws.SetHandler(c.ProxyWS(c.KVDelV1), api.EventKVDel)
		ws.SetHandler(c.KVWatchV1, api.EventKVWatch)

		router.Get(api.PathApiV1Watch, func(ctx web.Context) {
			ws.Handling(ctx.Response(), ctx.Request())
		})

		router.Get(api.PathApiV1KV, c.ProxyRest(c.KVGetV1))
		router.Put(api.PathApiV1KV, c.ProxyRest(c.KVSetV1))
		router.Delete(api.PathApiV1KV, c.ProxyRest(c.KVDelV1))
		router.Get(api.PathApiV1KVSearch, c.ProxyRest(c.KVSearchV1))
		router.Get(api.PathApiV1KVList, c.ProxyRest(c.KVListV1))
	},
}

Functions

This section is empty.

Types

type AppV1

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

func New

func New(db *db.DB, l xlog.Logger) *AppV1

func (*AppV1) Broadcast

func (v *AppV1) Broadcast(key string, eid event.Id, m interface{})

func (*AppV1) Down

func (v *AppV1) Down() error

func (*AppV1) KVDelV1

func (v *AppV1) KVDelV1(ctx *Props) error

func (*AppV1) KVGetV1

func (v *AppV1) KVGetV1(ctx *Props) error

func (*AppV1) KVListV1

func (v *AppV1) KVListV1(ctx *Props) error

func (*AppV1) KVSearchV1

func (v *AppV1) KVSearchV1(ctx *Props) error

func (*AppV1) KVSetV1

func (v *AppV1) KVSetV1(ctx *Props) error

func (*AppV1) KVWatchV1

func (v *AppV1) KVWatchV1(w server.Response, r server.Request, m server.Meta) error

func (*AppV1) ProxyRest

func (v *AppV1) ProxyRest(call func(p *Props) error) func(ctx web.Context)

func (*AppV1) ProxyWS

func (v *AppV1) ProxyWS(call func(p *Props) error) func(server.Response, server.Request, server.Meta) error

func (*AppV1) SetBroadcastHandler

func (v *AppV1) SetBroadcastHandler(call func(eid event.Id, m interface{}, cids ...string))

func (*AppV1) Up

func (v *AppV1) Up(ctx xc.Context) error

type EntitiesKV

type EntitiesKV []EntityKV

func (EntitiesKV) MarshalEasyJSON

func (v EntitiesKV) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EntitiesKV) MarshalJSON

func (v EntitiesKV) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EntitiesKV) UnmarshalEasyJSON

func (v *EntitiesKV) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EntitiesKV) UnmarshalJSON

func (v *EntitiesKV) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type EntitiesService added in v0.1.1

type EntitiesService []EntityService

func (EntitiesService) MarshalEasyJSON added in v0.1.1

func (v EntitiesService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EntitiesService) MarshalJSON added in v0.1.1

func (v EntitiesService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EntitiesService) UnmarshalEasyJSON added in v0.1.1

func (v *EntitiesService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EntitiesService) UnmarshalJSON added in v0.1.1

func (v *EntitiesService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type EntityKV

type EntityKV struct {
	Key   string  `json:"k"`
	Value *string `json:"v"`
}

func (*EntityKV) FromDB

func (v *EntityKV) FromDB(item db.EntityKV)

func (EntityKV) MarshalEasyJSON

func (v EntityKV) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EntityKV) MarshalJSON

func (v EntityKV) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (EntityKV) ToDB

func (v EntityKV) ToDB() db.EntityKV

func (*EntityKV) UnmarshalEasyJSON

func (v *EntityKV) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EntityKV) UnmarshalJSON

func (v *EntityKV) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*EntityKV) UseEmptyValue

func (v *EntityKV) UseEmptyValue()

type EntityService added in v0.1.1

type EntityService struct {
	Name    string   `json:"n"`
	Address string   `json:"a,omitempty"`
	Tags    []string `json:"t,omitempty"`
	Health  string   `json:"h,omitempty"`
}

func (EntityService) MarshalEasyJSON added in v0.1.1

func (v EntityService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (EntityService) MarshalJSON added in v0.1.1

func (v EntityService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*EntityService) UnmarshalEasyJSON added in v0.1.1

func (v *EntityService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*EntityService) UnmarshalJSON added in v0.1.1

func (v *EntityService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Props

type Props struct {
	Decode func(in interface{}) error
	Encode func(in interface{})
	Log    func(key string, err error, suffix string)
}

Jump to

Keyboard shortcuts

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