Documentation
¶
Index ¶
- Constants
- func Call(clientHost host.Host, protoTag string, call *EdgeCall) ([]byte, error)
- func CallWithFrom(clientHost host.Host, protoTag string, call *EdgeCall, from types.Address) ([]byte, error)
- func WriteSignedResponse(w http.ResponseWriter, info []byte, endpoint *Endpoint)
- type AppPeer
- type Application
- type ApplicationStore
- type EdgeCall
- type Endpoint
- func (e *Endpoint) AddHandler(url string, handler func(w http.ResponseWriter, r *http.Request))
- func (e *Endpoint) Close()
- func (e *Endpoint) GetEndpointApplication() *Application
- func (e *Endpoint) GetHandlerList() []string
- func (e *Endpoint) SetAppOrigin(appOrigin string)
- func (e *Endpoint) SetSigner(s proof.Signer)
- func (e *Endpoint) SubscribeEvents() Subscription
- type EndpointHandler
- type Event
- type EventType
- type MockSubscription
- type Network
- type PeerMap
- type Subscription
- type SyncAppPeerClient
- type SyncAppPeerService
- type Syncer
Constants ¶
View Source
const (
DefaultAppStatusPublishDuration = 15 * 60 * time.Second
)
View Source
const (
DefaultAppStatusSyncDuration = 30 * time.Second
)
View Source
const (
ProtoTagEcApp = "/em-app"
)
View Source
const (
SyncAppPeerClientLoggerName = "sync-app-peer-client"
)
Variables ¶
This section is empty.
Functions ¶
func CallWithFrom ¶
func WriteSignedResponse ¶
func WriteSignedResponse(w http.ResponseWriter, info []byte, endpoint *Endpoint)
Types ¶
type AppPeer ¶
type AppPeer struct {
// identifier
ID string
// name
Name string
// relay string
Relay string
// addr string
Addr string
// app origin name string
AppOrigin string
// ai model hash string
ModelHash string
// mac addr
Mac string
// memory info
MemInfo string
// cpu info
CpuInfo string
// peer's distance
Distance *big.Int
// app startup time
Starup_time uint64
// app uptime
Uptime uint64
// amount of slots currently occupying the app
Guage_height uint64
// max limit
Guage_max uint64
// average e power value
AveragePower float32
//gpu info
GpuInfo string
// version
Version string
}
type Application ¶
type Application struct {
Name string
Tag string
Version string
PeerID peer.ID
// ip4 addr string
IpAddr string
// ai app origin name
AppOrigin string
// ai model hash string
ModelHash string
// mac addr
Mac string
// memory info
MemInfo string
// cpu info
CpuInfo string
// gpu info
GpuInfo string
// app startup time
StartupTime uint64
// app uptime
Uptime uint64
// amount of slots currently occupying the app
GuageHeight uint64
// max limit
GuageMax uint64
// average e power value
AveragePower float32
// relay host
RelayHost string
// proxy port of relay
RelayProxyPort uint64
}
func (*Application) Copy ¶
func (a *Application) Copy() *Application
type ApplicationStore ¶
type ApplicationStore interface {
// ApplicationStore returns the application of endpoint
GetEndpointApplication() *Application
}
type EdgeCall ¶
type EdgeCall struct {
PeerId string `json:"peerId"`
Endpoint string `json:"endpoint"`
Input json.RawMessage `json:"input"`
}
type Endpoint ¶
func NewApplicationEndpoint ¶
func (*Endpoint) AddHandler ¶
func (*Endpoint) GetEndpointApplication ¶
func (e *Endpoint) GetEndpointApplication() *Application
func (*Endpoint) GetHandlerList ¶
func (*Endpoint) SetAppOrigin ¶
func (*Endpoint) SetSigner ¶
SetSigner sets the signer the endpoint will use to validate an edge call response's signature.
func (*Endpoint) SubscribeEvents ¶
func (e *Endpoint) SubscribeEvents() Subscription
SubscribeEvents returns a application event subscription
type EndpointHandler ¶
type EndpointHandler struct {
// contains filtered or unexported fields
}
func (*EndpointHandler) AddHandler ¶
func (h *EndpointHandler) AddHandler(url string, handler func(w http.ResponseWriter, r *http.Request))
func (*EndpointHandler) ServeHTTP ¶
func (h *EndpointHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Event ¶
type Event struct {
// New Application
NewApp []*Application
// Type is the type of event
Type EventType
// Source is the source that generated the blocks for the event
// right now it can be either the Sealer or the Syncer
Source string
}
Event is the application event that gets passed to the listeners
func (*Event) AddNewApp ¶
func (e *Event) AddNewApp(newApp *Application)
AddNewHeader appends a header to the event's NewChain array
func (*Event) LatestApp ¶
func (e *Event) LatestApp() *Application
Header returns the latest block header for the event
type MockSubscription ¶
type MockSubscription struct {
// contains filtered or unexported fields
}
func NewMockSubscription ¶
func NewMockSubscription() *MockSubscription
func (*MockSubscription) Close ¶
func (m *MockSubscription) Close()
func (*MockSubscription) GetEvent ¶
func (m *MockSubscription) GetEvent() *Event
func (*MockSubscription) GetEventCh ¶
func (m *MockSubscription) GetEventCh() chan *Event
func (*MockSubscription) Push ¶
func (m *MockSubscription) Push(e *Event)
type Network ¶
type Network interface {
// AddrInfo returns Network Info
AddrInfo() *peer.AddrInfo
// RegisterProtocol registers gRPC service
RegisterProtocol(string, network.Protocol)
// Peers returns current connected peers
Peers() []*network.PeerConnInfo
// SubscribeCh returns a channel of peer event
SubscribeCh(context.Context) (<-chan *event.PeerEvent, error)
// GetPeerDistance returns the distance between the node and given peer
GetPeerDistance(peer.ID) *big.Int
// NewProtoConnection opens up a new stream on the set protocol to the peer,
// and returns a reference to the connection
NewProtoConnection(protocol string, peerID peer.ID) (*rawGrpc.ClientConn, error)
// NewTopic Creates New Topic for gossip
NewTopic(protoID string, obj proto.Message) (*network.Topic, error)
// IsConnected returns the node is connecting to the peer associated with the given ID
IsConnected(peerID peer.ID) bool
// SaveProtocolStream saves stream
SaveProtocolStream(protocol string, stream *rawGrpc.ClientConn, peerID peer.ID)
// CloseProtocolStream closes stream
CloseProtocolStream(protocol string, peerID peer.ID) error
}
type Subscription ¶
Subscription is the application subscription interface
type SyncAppPeerClient ¶
type SyncAppPeerClient interface {
// Start processes for SyncAppPeerClient
Start(topicSubFlag bool) error
// Close terminates running processes for SyncAppPeerClient
Close()
// GetPeerStatus fetches peer status
GetPeerStatus(id peer.ID) (*AppPeer, error)
// GetPeerData fetches peer data
GetPeerData(peerID peer.ID, dataHash string, timeout time.Duration) (map[string][]byte, error)
// GetConnectedPeerStatuses fetches the statuses of all connecting peers
GetConnectedPeerStatuses() []*AppPeer
// GetPeerStatusUpdateCh returns a channel of peer's status update
GetPeerStatusUpdateCh() <-chan *AppPeer
// GetPeerConnectionUpdateEventCh returns peer's connection change event
GetPeerConnectionUpdateEventCh() <-chan *event.PeerEvent
// CloseStream close a stream
CloseStream(peerID peer.ID) error
// DisablePublishingPeerStatus disables publishing status in syncer topic
DisablePublishingPeerStatus()
// EnablePublishingPeerStatus enables publishing status in syncer topic
EnablePublishingPeerStatus()
// PublishApplicationStatus publish application status
PublishApplicationStatus(status *proto.AppStatus)
// SubscribeAppEvents returns a application event subscription
SubscribeAppEvents() Subscription
}
func NewSyncAppPeerClient ¶
func NewSyncAppPeerClient( logger hclog.Logger, network Network, host host.Host, applicationStore ApplicationStore, ) SyncAppPeerClient
type SyncAppPeerService ¶
type SyncAppPeerService interface {
// Start starts server
Start()
// Close terminates running processes for SyncPeerService
Close() error
}
func NewSyncAppPeerService ¶
func NewSyncAppPeerService( logger hclog.Logger, network *network.Server, applicationStore ApplicationStore, ) SyncAppPeerService
type Syncer ¶
type Syncer interface {
// Start starts syncer processes
Start(topicSubFlag bool) error
// Close terminates syncer process
Close() error
// GetAppPeer get AppPeer by PeerID
GetAppPeer(id string) *AppPeer
}
func NewSyncer ¶
func NewSyncer( logger hclog.Logger, syncAppPeerClient SyncAppPeerClient, syncAppPeerService SyncAppPeerService, host host.Host, applicationStore ApplicationStore, ) Syncer
Source Files
¶
Click to show internal directories.
Click to hide internal directories.