github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/achaemenid/manifest.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package achaemenid
     4  
     5  import (
     6  	"crypto/sha512"
     7  	"time"
     8  
     9  	etime "../earth-time"
    10  	"../protocol"
    11  )
    12  
    13  // Manifest store server manifest data
    14  // All string slice is multi language and in order by ManifestLanguages order
    15  type Manifest struct {
    16  	Society     string
    17  	SocietyUUID [32]byte
    18  	SocietyID   protocol.SocietyID
    19  	DomainName  string
    20  	AppID       [32]byte // Hash of domain act as Application ID too
    21  	Email       string
    22  	Icon        string
    23  	AppDeatil   map[protocol.LanguageID]AppDetail
    24  
    25  	RequestedPermission []uint32 // ServiceIDs from PersiaOS services e.g. InternetInBackground, Notification, ...
    26  	TechnicalInfo       TechnicalInfo
    27  	NetworkInfo         NetworkInfo
    28  	DeployInfo          DeployInfo
    29  }
    30  
    31  func (ma *Manifest) init() {
    32  	ma.AppID = sha512.Sum512_256(convert.UnsafeStringToByteSlice(ma.DomainName))
    33  }
    34  
    35  type AppDetail struct {
    36  	Organization   string
    37  	Name           string
    38  	Description    string
    39  	TermsOfService string
    40  	Licence        string
    41  	TAGS           []string // Use to categorized apps e.g. Music, GPS, ...
    42  }
    43  
    44  // TechnicalInfo store some technical information but may different from really server condition!
    45  type TechnicalInfo struct {
    46  	// Shutdown settings
    47  	ShutdownDelay time.Duration // the server will wait for at least this amount of time for active streams to finish!
    48  
    49  	// Minimum hardware specification for each instance of application.
    50  	CPUCores uint8  // Number
    51  	CPUSpeed uint64 // Hz
    52  	RAM      uint64 // Byte
    53  	GPU      uint64 // Hz
    54  	Network  uint64 // Byte per second
    55  	Storage  uint64 // Byte, HHD||SSD||... indicate by DataCentersClassForDataStore
    56  }
    57  
    58  // NetworkInfo store some network information.
    59  type NetworkInfo struct {
    60  	// Application Overal rate limit
    61  	MaxOpenConnection     uint64         // The maximum number of concurrent connections the app may serve.
    62  	ConnectionIdleTimeout etime.Duration // In seconds
    63  	// MaxStreamHeaderSize   uint64 // For stream protocols with variable header size like HTTP
    64  	// MaxStreamPayloadSize  uint64 // For stream protocols with variable payload size like sRPC, HTTP, ...
    65  
    66  	// Guest rete limit - Connection.OwnerType==0
    67  	GuestMaxConnections            uint64 // 0 means App not accept guest connection.
    68  	GuestMaxUserConnectionsPerAddr uint64
    69  	GuestMaxConcurrentStreams      uint32
    70  	GuestMaxStreamConnectionDaily  uint32 // Max open stream per day for a guest connection. overflow will drop on creation!
    71  	GuestMaxServiceCallDaily       uint64 // 0 means no limit and good for PayAsGo strategy!
    72  	GuestMaxBytesSendDaily         uint64
    73  	GuestMaxBytesReceiveDaily      uint64
    74  	GuestMaxPacketsSendDaily       uint64
    75  	GuestMaxPacketsReceiveDaily    uint64
    76  
    77  	// Registered rate limit - Connection.OwnerType==1
    78  	RegisteredMaxConnections            uint64
    79  	RegisteredMaxUserConnectionsPerAddr uint64
    80  	RegisteredMaxConcurrentStreams      uint32
    81  	RegisteredMaxStreamConnectionDaily  uint32 // Max open stream per day for a Registered user connection. overflow will drop on creation!
    82  	RegisteredMaxServiceCallDaily       uint64 // 0 means no limit and good for PayAsGo strategy!
    83  	RegisteredMaxBytesSendDaily         uint64
    84  	RegisteredMaxBytesReceiveDaily      uint64
    85  	RegisteredMaxPacketsSendDaily       uint64
    86  	RegisteredMaxPacketsReceiveDaily    uint64
    87  
    88  	// If you want to know Connection.OwnerType>1 rate limit strategy, You must read server codes!!
    89  }
    90  
    91  // DeployInfo store some application deployment information.
    92  type DeployInfo struct {
    93  	// Distribution
    94  	DistributeOutOfSociety bool          // Allow to run service-only instance of app out of original society belong to.
    95  	DataCentersClass       uint8         // 0:FirstClass 256:Low-Quality default:5
    96  	MaxNodeNumber          uint32        // default:3
    97  	NodeFailureTimeOut     time.Duration // Max suggestion is 6 hour, other service only node replace failed node! not use in network failure, it is handy proccess!
    98  }