ucs

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

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 14 Imported by: 0

README

Unity Cache Server

.. in Go

ARCHIVED

This was a mostly do-some-work-related-Go. As I no longer work with Unity, I don't really have a need for this, nor can I test it in any meaningful capacity.

If you like the project, feel free to fork the project - or petition Unity to take it over.

Installation from source

go get -u github.com/msiebuhr/ucs/cmd/ucs
ucs

This will listen for cache-requests on TCP port 8126 and start a small web-server on http://localhost:9126 with setup-instructinos and Promehteus metrics.

Full usage options are shown with ucs -h. Note that options can be passed as environment variables, making the following examples equivalent:

ucs -quota 10GB
ucs --quota 10GB
QUOTA=10GB ucs

As it is generally recommended to use a cache per major Unity Release and project, the server supports namespaces. This is done by using multiple -port arguments or comma-separated list.

ucs -port=8126 -port=name:8127
ucs -port=8126,name:8127
PORT=8126,name:8127 ucs

Each name/port will have a seperate cache, but garbage-collected as one (so old projects' data will all but vanish and new ones will get lots of space).

For convenience, ports can be named as in name:8127. Is is used for the file-system path, display on the help-page and in metrics. If the name is left out, the port-number also becomes the name.

Load testing

There's also a quick-and-dirty loadtest utility, ucs-bender:

go get -u github.com/msiebuhr/ucs/cmd/ucs-bender
ucs-bender # Will run against localhost

Miscellaneous

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fuzz

func Fuzz(data []byte) int

func PrettyUuidAndHash

func PrettyUuidAndHash(d []byte) string

Types

type BulkClient

type BulkClient struct {
	Conn     io.ReadWriteCloser
	Callback func(K cache.Kind, uuidAndHash []byte, hit bool, data io.Reader)
	// contains filtered or unexported fields
}

BulkClient sends requests in bulk, like Unity does. That is, it sends *all* get-requests before it begins reading responses.

func NewBulkClientConn

func NewBulkClientConn(conn io.ReadWriteCloser) *BulkClient

func (BulkClient) Close

func (c BulkClient) Close() error

Close the connection. Unpolite, I guess, but that's what Unity is observed to do in the wild.

func (*BulkClient) Execute

func (c *BulkClient) Execute() error

func (*BulkClient) Get

func (c *BulkClient) Get(K cache.Kind, uuidAndHash []byte) error

Enqueue a get-request and wait for response to show up

func (*BulkClient) GetCallback

func (c *BulkClient) GetCallback(callback func(K cache.Kind, uuidAndHash []byte, hit bool, data io.Reader))

Callback that will get replies for get-requests

func (BulkClient) NegotiateVersion

func (c BulkClient) NegotiateVersion(my uint32) (uint32, error)

func (*BulkClient) Put

func (c *BulkClient) Put(uuidAndHash []byte, i *PutObject, a *PutObject, r *PutObject)

Putting data

func (BulkClient) Quit

func (c BulkClient) Quit() error

Gracefully quit the current connection and close down

type PutObject

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

PUT Objects. A plain reader, but we need a size up-front. TODO: Implement lot's of magic (file sizes, string.NewReader) etc.

func NewPutObject

func NewPutObject(r io.Reader, size int) *PutObject

func PutString

func PutString(s string) *PutObject

PUT string wrapper

type Server

type Server struct {
	Cache     cache.Cacher
	Log       *log.Logger
	Namespace string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(options ...func(*Server)) *Server

Set up a new server

func (*Server) Listen

func (s *Server) Listen(ctx context.Context, address string) error

func (*Server) Listener

func (s *Server) Listener(ctx context.Context, listener *net.TCPListener) error

func (*Server) Stop

func (s *Server) Stop()

Directories

Path Synopsis
cmd
ucs

Jump to

Keyboard shortcuts

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