resolver

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package resolver provides interface and default implementation of resolvers for getting objects from references. Interface Resolver uses interface{} type for reference, class and proxy (which GetObject returns), because in future implementation its going to be plugin. Virtual machine will be use it and provide resolving logic.

Usage:

package main

import (
	"github.com/insolar/insolar/genesis/model/class"
	"github.com/insolar/insolar/genesis/model/object"
}

func main() {
	resolver := NewChildResolver(parent)
	obj, err := resolver.GetObject(ref, class.ObjectID)
	res := obj.(object.Object)
}

Proxy provides interface and default implementation of proxy. It inherited by SmartContractProxy and Factory

Usage:

proxy.SetReference(Reference) sets reference to proxy.
proxy.GetReference() gets reference from proxy.
proxy.GetParent() always returns nil.
proxy.GetClassID() is a proxy call for instance method.

ReferenceContainer provides methods for store Reference as Proxy

Usage:

ref, _ := object.NewReference(domain, record, object.GlobalScope)
container = NewReferenceContainer(ref)

container.GetClassID()         // return string representation of object's class.
container.GetStoredReference() // returns stored reference.

Index

Constants

This section is empty.

Variables

View Source
var GlobalResolver = newGlobalResolver()

GlobalResolver is a public globalResolver instance for resolving all global references.

Functions

This section is empty.

Types

type BaseProxy added in v0.0.2

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

BaseProxy is a base implementation of Proxy.

func (*BaseProxy) GetClassID added in v0.0.2

func (bp *BaseProxy) GetClassID() string

GetClassID is a proxy call for instance method.

func (*BaseProxy) GetParent added in v0.0.2

func (bp *BaseProxy) GetParent() object.Parent

GetParent always returns nil.

func (*BaseProxy) GetReference added in v0.0.2

func (bp *BaseProxy) GetReference() object.Reference

GetReference is a proxy call for instance method.

func (*BaseProxy) SetReference added in v0.0.2

func (bp *BaseProxy) SetReference(reference object.Reference)

SetReference is a proxy call for instance method.

type Handler added in v0.0.2

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

Handler should resolve references from any allowed scopes.

func NewHandler added in v0.0.2

func NewHandler(p interface{}) *Handler

NewHandler creates new resolverHandler instance.

func (*Handler) GetObject added in v0.0.2

func (r *Handler) GetObject(reference interface{}, classID interface{}) (interface{}, error)

GetObject resolves object by its reference and return its proxy.

func (*Handler) InitGlobalMap added in v0.0.2

func (r *Handler) InitGlobalMap(globalInstanceMap *map[string]Proxy)

InitGlobalMap sets globalInstanceMap into globalResolver.

type Proxy

type Proxy interface {
	object.Child
	GetReference() object.Reference
	SetReference(reference object.Reference)
}

Proxy marks instance as proxy object.

type ReferenceContainer added in v0.0.2

type ReferenceContainer struct {
	BaseProxy
	// contains filtered or unexported fields
}

ReferenceContainer is a implementation of Proxy for containerization purpose.

func NewReferenceContainer added in v0.0.2

func NewReferenceContainer(ref object.Reference) *ReferenceContainer

NewReferenceContainer creates new container for reference.

func (*ReferenceContainer) GetClassID added in v0.0.2

func (rc *ReferenceContainer) GetClassID() string

GetClassID return string representation of object's class.

func (*ReferenceContainer) GetStoredReference added in v0.0.2

func (rc *ReferenceContainer) GetStoredReference() object.Reference

GetStoredReference returns stored reference.

type Resolver

type Resolver interface {
	GetObject(reference interface{}, classID interface{}) (interface{}, error)
}

Resolver marks that instance have ability to get proxy objects by its reference.

Jump to

Keyboard shortcuts

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