server

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Internal code for the cyandb server

Index

Constants

View Source
const (
	// Use this for default db functionality
	DefaultDBPath = "/data/cyan/"
	DefaultPort   = 8080
)

Variables

This section is empty.

Functions

func GetAsBytes

func GetAsBytes(f *os.File) ([]byte, []byte, error)

GetAsBytes gets the key and value as bytes

func ReadKeyVal

func ReadKeyVal(currKeyLen uint32, err error, f *os.File, currValLen uint32) (
	error,
	int64,
	string,
	[]byte,
	string,
	error,
	int64,
	bool,
)

ReadKeyVal reads the key and value from the current point in the file

func Reverse

func Reverse(nums []int64) []int64

func Uint32ToByteArr

func Uint32ToByteArr(num uint32) []byte

Uint32ToByteArr takes a 32 bit integer as input, converts it to a byte slice, and returns the byte slice

func VerifyGetQuery

func VerifyGetQuery(query *Query) ([]byte, bool)

func VerifySetQuery

func VerifySetQuery(query *Query) ([]byte, bool)

Types

type Query

type Query struct {
	Command string
	Args    []string
}

func NewQuery

func NewQuery(command string, args []string) *Query

NewQuery generates a query

func Parse

func Parse(text []byte) (error, *Query)

Parse parses a command

type QueryRunner

type QueryRunner struct {
	Server *Server
}

func NewQueryRunner

func NewQueryRunner(server *Server) *QueryRunner

func (*QueryRunner) RunQuery

func (queryRunner *QueryRunner) RunQuery(err error, query *Query) []byte

type Server

type Server struct {
	Location string
	Port     int
}

Server is the struct definition for the server I will add more to this once websockets are introduced

func CreateServer

func CreateServer(path string, port int) *Server

CreateServer creates a server struct

func (*Server) Get

func (server *Server) Get(key string) (string, error, int64)

Get returns a value from the database given a corresponding key

func (*Server) Set

func (server *Server) Set(key string, val string) (string, error)

Set adds a key value pair to a database Serialization model:

[4 bytes len(key)][4 bytes len(val)][len(key) bytes key][len(val) bytes val]

func (*Server) SetExisting

func (server *Server) SetExisting(keyAsBytes []byte, valAsBytes []byte, lenKey uint32, lenVal uint32,
	originalValue string, existingPos int64) error

SetExisting Sets value for an existing key

func (*Server) StartServer

func (server *Server) StartServer()

StartServer starts the websocket server

Jump to

Keyboard shortcuts

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