Documentation
¶
Overview ¶
and (Abyss Neighbor Discovery) algorithm defines worlds in abyss network. A World is created by OpenWorld or JoinWorld call on AND, which is the algorithm provider. Calling world writes back events synchronously. World algorithm may request a peer through event. On host-side event consumer prvides peer (by dialing or just giving connected peer). When a peer closes, the host calls PeerClose() to each world that references the peer. By this way, the host has full control over peer references.
Index ¶
- Constants
- func SendJDN_NoWorld(peer_session ANDPeerSession, code int, message string) error
- func SendRST_UnexpectedArbitraryWorld(peer_session ANDPeerSession, unknown_wsid uuid.UUID) error
- type AND
- type ANDFullPeerSessionInfo
- type ANDPeerSession
- type ANDPeerSessionIdentity
- type ANDSessionState
- type ANDStatistics
- type CRR
- type EANDError
- type EANDObjectAppend
- type EANDObjectDelete
- type EANDPeerDiscard
- type EANDPeerRequest
- type EANDSessionClose
- type EANDSessionReady
- type EANDSessionRequest
- type EANDTimerRequest
- type EANDWorldEnter
- type EANDWorldLeave
- type IANDEvent
- type INVAL
- type JDN
- type JN
- type JNI
- type JOK
- type MEM
- type ObjectInfo
- type RST
- type RawCRR
- type RawJDN
- type RawJN
- type RawJNI
- type RawJOK
- type RawMEM
- type RawObjectInfo
- type RawRST
- type RawSJN
- type RawSOA
- type RawSOD
- type RawSessionInfoForDiscovery
- type RawSessionInfoForSJN
- type SJN
- type SOA
- type SOD
- type World
- func (w *World) AcceptSession(events ds.Queue, peer_session_identity ANDPeerSessionIdentity)
- func (w *World) CRR(events ds.Queue, peer_session ANDPeerSession, ...)
- func (w *World) CheckSanity()
- func (w *World) Close()
- func (w *World) DeclineSession(events ds.Queue, peer_session_identity ANDPeerSessionIdentity, code int, ...)
- func (w *World) IsExposable() bool
- func (w *World) JDN(events ds.Queue, peer ani.IAbyssPeer, code int, message string)
- func (w *World) JN(events ds.Queue, peer_session ANDPeerSession, timestamp time.Time)
- func (w *World) JNI(events ds.Queue, peer_session ANDPeerSession, ...)
- func (w *World) JOK(events ds.Queue, peer_session ANDPeerSession, timestamp time.Time, ...)
- func (w *World) MEM(events ds.Queue, peer_session ANDPeerSession, timestamp time.Time)
- func (w *World) ObjectAppend(peer_session_identities []ANDPeerSessionIdentity, objects []ObjectInfo)
- func (w *World) ObjectDelete(peer_session_identities []ANDPeerSessionIdentity, objectIDs []uuid.UUID)
- func (w *World) PeerConnected(events ds.Queue, peer ani.IAbyssPeer)
- func (w *World) PeerDisconnected(events ds.Queue, peer_id string)
- func (w *World) Peers() []ani.IAbyssPeer
- func (w *World) RST(events ds.Queue, peer_session ANDPeerSession)
- func (w *World) SJN(events ds.Queue, peer_session ANDPeerSession, ...)
- func (w *World) SOA(events ds.Queue, peer_session ANDPeerSession, objects []ObjectInfo)
- func (w *World) SOD(events ds.Queue, peer_session ANDPeerSession, objectIDs []uuid.UUID)
- func (w *World) SessionID() uuid.UUID
- func (w *World) TimerExpire(events ds.Queue)
Constants ¶
const ( JNC_REDUNDANT = 110 //Joiner-side problem JNC_NOT_FOUND = 404 JNC_DUPLICATE = 480 JNC_OVERRUN = 481 JNC_CANCELED = 498 JNC_CLOSED = 499 //Accepter-side response JNC_COLLISION = 520 JNC_EXPIRED = 530 JNC_REJECTED = 599 //Non-Joining state JNC_UNEXPECTED_WSID = 600 JNC_INVALID_STATES = 610 //Network issue JNC_DISCONNECTED = 700 )
const ( JNM_REDUNDANT = "Already Joined" JNM_NOT_FOUND = "Not Found" JNM_DUPLICATE = "Duplicate Join" JNM_OVERRUN = "World Session Overrun" JNM_CANCELED = "Join Canceled" JNM_CLOSED = "Peer Disconnected" JNM_COLLISION = "Session ID Collided" JNM_EXPIRED = "Join Expired" JNM_REJECTED = "Join Rejected" JNM_UNEXPECTED_WSID = "Unexpected Session ID" JNM_INVALID_STATES = "Invalid States" JNM_DISCONNECTED = "Disconnected" )
const INITIAL_WORLD_TIMER = 1000
Variables ¶
This section is empty.
Functions ¶
func SendJDN_NoWorld ¶ added in v0.1.202602121754
func SendJDN_NoWorld(peer_session ANDPeerSession, code int, message string) error
func SendRST_UnexpectedArbitraryWorld ¶ added in v0.1.202602121754
func SendRST_UnexpectedArbitraryWorld(peer_session ANDPeerSession, unknown_wsid uuid.UUID) error
Types ¶
type ANDFullPeerSessionInfo ¶ added in v0.1.202602121754
type ANDFullPeerSessionInfo struct {
PeerID string
AddressCandidates []netip.AddrPort
SessionID uuid.UUID
TimeStamp time.Time
RootCertificateDer []byte
HandshakeKeyCertificateDer []byte
}
ANDFullPeerSessionInfo provides all the information required to connect a peer, identify its world session, negotiate ordering. As a result, a peer who receives this can construct ANDFullPeerSession.
type ANDPeerSession ¶ added in v0.1.202602121754
type ANDPeerSession struct {
Peer ani.IAbyssPeer
SessionID uuid.UUID
}
ANDPeerSession is used to indirect a peer world session in IANDEvent.
type ANDPeerSessionIdentity ¶ added in v0.1.202602121754
ANDPeerSessionIdentity is used to indirect a peer world session, which is used in connection recovery.
type ANDSessionState ¶ added in v0.1.202602121754
type ANDSessionState int
const ( // WS_DC_JNI : disconnected, JNI received // (X) Peer, is_session_requested // (O) PeerID, SessionID, TimeStamp WS_DC_JNI ANDSessionState = iota + 1 // WS_CC : connected, no info. <<W_Joining>> // (X) SessionID, TimeStamp, is_session_requested WS_CC // WS_JN : JN received // (O) SessionID, TimeStamp, is_session_requested WS_JN // WS_RMEM_NJNI : MEM received, JNI not received. <<W_Joining>> // (X) is_session_requested // (O) SessionID, TimeStamp WS_RMEM_NJNI // WS_JNI : JNI received, MEM not received // (X) // (O) SessionID, TimeStamp is_session_requested WS_JNI // WS_RMEM : MEM received // (X) // (O) SessionID, TimeStamp, is_session_requested WS_RMEM // WS_TMEM : MEM/JOK sent // (X) // (O) SessionID, TimeStamp, is_session_requested WS_TMEM // WS_MEM : member // (X) // (O) SessionID, TimeStamp, is_session_requested WS_MEM )
func (ANDSessionState) String ¶ added in v0.1.202602121754
func (s ANDSessionState) String() string
type ANDStatistics ¶
type ANDStatistics struct {
JN_TX int
JOK_TX int
JDN_TX int
JNI_TX int
MEM_TX int
SJN_TX int
CRR_TX int
RST_TX int
SOA_TX int
SOD_TX int
JN_RX int
JOK_RX int
JDN_RX int
JNI_RX int
MEM_RX int
SJN_RX int
CRR_RX int
RST_RX int
SOA_RX int
SOD_RX int
}
func (*ANDStatistics) B ¶
func (s *ANDStatistics) B(i int)
func (*ANDStatistics) String ¶
func (s *ANDStatistics) String() string
func (*ANDStatistics) W ¶
func (s *ANDStatistics) W(i int)
type CRR ¶ added in v0.1.202602121754
type CRR struct {
SenderSessionID uuid.UUID
RecverSessionID uuid.UUID
MemberInfos []ANDPeerSessionIdentity
}
type EANDObjectAppend ¶ added in v0.1.202602121754
type EANDObjectAppend struct {
World *World
ANDPeerSession
Objects []ObjectInfo
}
type EANDObjectDelete ¶ added in v0.1.202602121754
type EANDObjectDelete struct {
World *World
ANDPeerSession
ObjectIDs []uuid.UUID
}
type EANDPeerDiscard ¶ added in v0.1.202602121754
type EANDPeerDiscard struct {
World *World
Peer ani.IAbyssPeer
}
type EANDPeerRequest ¶ added in v0.1.202602121754
type EANDSessionClose ¶ added in v0.1.202602121754
type EANDSessionClose struct {
World *World
ANDPeerSession
}
type EANDSessionReady ¶ added in v0.1.202602121754
type EANDSessionReady struct {
World *World
ANDPeerSession
}
type EANDSessionRequest ¶ added in v0.1.202602121754
type EANDSessionRequest struct {
World *World
ANDPeerSession
}
type EANDTimerRequest ¶ added in v0.1.202602121754
type EANDWorldEnter ¶ added in v0.1.202602121754
type EANDWorldLeave ¶ added in v0.1.202602121754
type IANDEvent ¶ added in v0.1.202602121754
type IANDEvent any
IANDEvent conveys event/request from AND to host. a session may close before ready, but never before request. No event should be pushed after JoinFail or WorldLeave. This must be a pointer for an EAND struct.
type JNI ¶ added in v0.1.202602121754
type JNI struct {
SenderSessionID uuid.UUID
RecverSessionID uuid.UUID
Neighbor ANDFullPeerSessionInfo
}
type ObjectInfo ¶ added in v0.1.202602121754
ObjectInfo is used to represent shared object.
type RawCRR ¶ added in v0.1.202602121754
type RawCRR struct {
SenderSessionID string
RecverSessionID string
MemberInfos []RawSessionInfoForSJN
}
type RawJNI ¶ added in v0.1.202602121754
type RawJNI struct {
SenderSessionID string
RecverSessionID string
Joiner RawSessionInfoForDiscovery
}
type RawJOK ¶ added in v0.1.202602121754
type RawJOK struct {
SenderSessionID string
RecverSessionID string
URL string
TimeStamp int64
Neighbors []RawSessionInfoForDiscovery
}
type RawObjectInfo ¶ added in v0.1.202602121754
type RawSJN ¶ added in v0.1.202602121754
type RawSJN struct {
SenderSessionID string
RecverSessionID string
MemberInfos []RawSessionInfoForSJN
}
type RawSOA ¶ added in v0.1.202602121754
type RawSOA struct {
SenderSessionID string
RecverSessionID string
Objects []RawObjectInfo
}
type RawSessionInfoForDiscovery ¶ added in v0.1.202602121754
type RawSessionInfoForDiscovery struct {
PeerID string
AddressCandidates []string
SessionID string
TimeStamp int64
RootCertificateDer []byte
HandshakeKeyCertificateDer []byte
}
func MakeRawSessionInfoForDiscovery ¶ added in v0.1.202602121754
func MakeRawSessionInfoForDiscovery(entry *peerWorldSessionState) RawSessionInfoForDiscovery
type RawSessionInfoForSJN ¶ added in v0.1.202602121754
func MakeRawSessionInfoForSJN ¶ added in v0.1.202602121754
func MakeRawSessionInfoForSJN(entry *peerWorldSessionState) RawSessionInfoForSJN
type SJN ¶ added in v0.1.202602121754
type SJN struct {
SenderSessionID uuid.UUID
RecverSessionID uuid.UUID
MemberInfos []ANDPeerSessionIdentity
}
type SOA ¶ added in v0.1.202602121754
type SOA struct {
SenderSessionID uuid.UUID
RecverSessionID uuid.UUID
Objects []ObjectInfo
}
type World ¶ added in v0.1.202602121754
type World struct {
// contains filtered or unexported fields
}
World is a state machine for a world and its member/related peers. Removing join target from a world breakes it, so be careful. A world must be externally locked, using the embedded sync.Mutex. This gives better control over call and event synchronization for the host.
func (*World) AcceptSession ¶ added in v0.1.202602121754
func (w *World) AcceptSession(events ds.Queue, peer_session_identity ANDPeerSessionIdentity)
func (*World) CRR ¶ added in v0.1.202602121754
func (w *World) CRR(events ds.Queue, peer_session ANDPeerSession, member_infos []ANDPeerSessionIdentity)
func (*World) CheckSanity ¶ added in v0.1.202602121754
func (w *World) CheckSanity()
func (*World) Close ¶ added in v0.1.202602121754
func (w *World) Close()
Close does not take events argument, as the world is closed immediately. no events are meaningful afterwards.
func (*World) DeclineSession ¶ added in v0.1.202602121754
func (*World) IsExposable ¶ added in v0.1.202602121754
IsExposable checks if the world joining procedure is finished and the world information is set.
func (*World) JNI ¶ added in v0.1.202602121754
func (w *World) JNI(events ds.Queue, peer_session ANDPeerSession, member_info ANDFullPeerSessionInfo)
func (*World) JOK ¶ added in v0.1.202602121754
func (w *World) JOK(events ds.Queue, peer_session ANDPeerSession, timestamp time.Time, world_url string, member_infos []ANDFullPeerSessionInfo)
func (*World) ObjectAppend ¶ added in v0.1.202602121754
func (w *World) ObjectAppend(peer_session_identities []ANDPeerSessionIdentity, objects []ObjectInfo)
func (*World) ObjectDelete ¶ added in v0.1.202602121754
func (w *World) ObjectDelete(peer_session_identities []ANDPeerSessionIdentity, objectIDs []uuid.UUID)
func (*World) PeerConnected ¶ added in v0.1.202602121754
func (w *World) PeerConnected(events ds.Queue, peer ani.IAbyssPeer)
PeerConnected must never raise EANDPeerDiscard event for the connected peer.
func (*World) PeerDisconnected ¶ added in v0.1.202602121754
We don't verify everything like we did for the other messages; we trust the caller. PeerDisconnected should raise EANDPeerDiscoard event for the peer.
func (*World) Peers ¶ added in v0.1.202602121754
func (w *World) Peers() []ani.IAbyssPeer
func (*World) RST ¶ added in v0.1.202602121754
func (w *World) RST(events ds.Queue, peer_session ANDPeerSession)
func (*World) SJN ¶ added in v0.1.202602121754
func (w *World) SJN(events ds.Queue, peer_session ANDPeerSession, member_infos []ANDPeerSessionIdentity)
func (*World) SOA ¶ added in v0.1.202602121754
func (w *World) SOA(events ds.Queue, peer_session ANDPeerSession, objects []ObjectInfo)