github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/networking-connection.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package protocol 4 5 // Connection or App2AppConnection indicate how connection create and save in time series data. 6 // Each user pair with delegate-user has a chain that primary key is UserID+DelegateUserID 7 type Connection interface { 8 /* Connection data */ 9 HeaderID() NetworkLink_NextHeaderID 10 MTU() int 11 12 /* Peer data */ 13 LocalAddr() []byte 14 RemoteAddr() []byte 15 DomainName() string // if exist 16 UserID() UserID 17 DelegateUserID() UserID // Persons can delegate to things(as a user type) 18 19 Close() (err Error) // Just once 20 Revoke() (err Error) // Just once 21 22 Network_Status 23 OperationImportance 24 ConnectionLowLevelAPIs 25 Streams 26 ConnectionMetrics 27 } 28 29 // ConnectionLevelAPIs is low level APIs, don't use them in the services layer, if you don't know how it can be effect the application. 30 // It will use in chunks managing packages e.g. sRPC, QUIC, TCP, UDP, ... or Application layer protocols e.g. HTTP, ... 31 type ConnectionLowLevelAPIs interface { 32 NewPacket(payloadLen int) (packet []byte, payload []byte, err Error) 33 34 // Send transmitting in non blocking mode and just queue frames for congestion situations. 35 // Return error not related to packet situation, just about any hardware error. 36 // A situation might be occur that the port available when a packet queued, 37 // but when the time to send is come, the port broken and sender don't know about this. 38 // Due to speed matters in link layer, and it is very rare situation, it is better to ignore suddenly port unavailability. 39 // After return, caller can't reuse payload array anymore. 40 Send(packet []byte) (err Error) // to send data use Send() that exist in stream of each connection 41 }