service

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package service contains the implementation of the SUM gRPC service.

Index

Constants

View Source
const Version = "1.2.1"

Version holds the current version string of this software.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionPool

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

ExecutionPool is a pool of clones of a single VM that will be used to scale the execution of an oracle to different goroutines without locking one single shared VM.

func CreateExecutionPool

func CreateExecutionPool(vm *otto.Otto) *ExecutionPool

CreateExecutionPool creates an ExecutionPool object for the given VM.

func (*ExecutionPool) Get

func (p *ExecutionPool) Get() *VM

Get will wait until a VM object in the pool is signaled as free by whoever was using it and then return the first signaled free VM instance.

type Service

type Service struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Service represents a single instance of the Sum database service.

func New

func New(dataPath string, credsPath string, address string) (svc *Service, err error)

New loads records and oracles from a given path and returns a new instance of the *Service object.

func (*Service) CreateOracle

func (s *Service) CreateOracle(ctx context.Context, oracle *pb.Oracle) (*pb.OracleResponse, error)

CreateOracle compiles and stores a raw *pb.Oracle object. If successful, the identifier of the newly created oracle is returned as the response message.

func (*Service) CreateRecord

func (s *Service) CreateRecord(ctx context.Context, record *pb.Record) (*pb.RecordResponse, error)

CreateRecord creates and stores a new *pb.Record object. If successful, the identifier of the record is returned as the response message.

func (*Service) DeleteOracle

func (s *Service) DeleteOracle(ctx context.Context, query *pb.ById) (*pb.OracleResponse, error)

DeleteOracle removes an oracle from the storage given its identifier.

func (*Service) DeleteRecord

func (s *Service) DeleteRecord(ctx context.Context, query *pb.ById) (*pb.RecordResponse, error)

DeleteRecord removes a record from the storage given its identifier.

func (*Service) FindOracle

func (s *Service) FindOracle(ctx context.Context, query *pb.ByName) (*pb.OracleResponse, error)

FindOracle returns a list of raw *pb.Oracle objects that match the provided name.

func (*Service) FindRecords

func (s *Service) FindRecords(ctx context.Context, query *pb.ByMeta) (*pb.FindResponse, error)

FindRecords returns a FindResponse object corresponding to the records that matched the search criteria.

func (*Service) Info

func (s *Service) Info(ctx context.Context, dummy *pb.Empty) (*pb.ServerInfo, error)

Info returns a *pb.ServerInfo object with various realtime information about the service and its runtime.

func (*Service) ListOracles added in v1.2.0

func (s *Service) ListOracles(ctx context.Context, list *pb.ListRequest) (*pb.OracleListResponse, error)

ListOracles returns list of oracles given a ListRequest object.

func (*Service) ListRecords

func (s *Service) ListRecords(ctx context.Context, list *pb.ListRequest) (*pb.RecordListResponse, error)

ListRecords returns list of records given a ListRequest object.

func (*Service) NumOracles

func (s *Service) NumOracles() int

NumOracles returns the number of oracles currently loaded by the service.

func (*Service) NumRecords

func (s *Service) NumRecords() int

NumRecords returns the number of records currently loaded by the service.

func (*Service) ReadOracle

func (s *Service) ReadOracle(ctx context.Context, query *pb.ById) (*pb.OracleResponse, error)

ReadOracle returns a raw *pb.Oracle object given its identifier.

func (*Service) ReadRecord

func (s *Service) ReadRecord(ctx context.Context, query *pb.ById) (*pb.RecordResponse, error)

ReadRecord returns a raw *pb.Record object given its identifier.

func (*Service) Run

func (s *Service) Run(ctx context.Context, call *pb.Call) (resp *pb.CallResponse, err error)

Run executes a compiled oracle given its identifier and the arguments in the *pb.Call object.

func (*Service) UpdateOracle

func (s *Service) UpdateOracle(ctx context.Context, oracle *pb.Oracle) (*pb.OracleResponse, error)

UpdateOracle updates the contents of an oracle with the ones of a raw *pb.Oracle object given its identifier.

func (*Service) UpdateRecord

func (s *Service) UpdateRecord(ctx context.Context, record *pb.Record) (*pb.RecordResponse, error)

UpdateRecord updates the contents of a record with the ones of a raw *pb.Record object given its identifier.

type VM

type VM struct {
	*otto.Otto
	// contains filtered or unexported fields
}

VM is only used to wrap the vm object and give a Release method the caller can defer in order to free the VM itself transparently.

func (*VM) Release

func (w *VM) Release()

Release adds this object back to the free list of the pool.

Jump to

Keyboard shortcuts

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