github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/protocol/application.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package protocol 4 5 // Application immutable runtime settings 6 const ( 7 // AppLanguage store global language to use by any locale text selector. 8 AppLanguage = LanguageEnglish 9 10 // AppMode_Dev use to indicate that app can do some more logic e.g. 11 // - Save more logs 12 // - Add more services like net/http/pprof for better debugging 13 // - Add more pages that just need only for developers 14 AppMode_Dev = true 15 ) 16 17 // App is default global protocol.Application like window global variable in browsers. 18 // You must assign to it by any object implement protocol.Application on your main.go file. Suggestion: 19 // - Server App >> protocol.App = &achaemenid.App 20 // - GUI App >> protocol.App = &gui.Application 21 var App Application 22 23 // Application is the interface that must implement by any Application. 24 type Application interface { 25 Engine() ApplicationEngine 26 27 SoftwareStatus() SoftwareStatus 28 Status() ApplicationState 29 // Listen to the app state changes. Can return the channel instead of get as arg, but a channel listener can lost very fast app state changing. 30 // This is because when the first goroutine blocks the channel all other goroutines must wait in line. When the channel is unblocked, 31 // the state has already been received and removed from the channel so the next goroutine in line gets the next state value. 32 NotifyState(notifyBy chan ApplicationState) 33 Shutdown() 34 35 Cluster 36 StoragesLocal 37 StoragesCache 38 Logger 39 Services 40 Errors 41 Connections 42 NetworkApplicationMultiplexer 43 EventTarget 44 45 // Server specific applications 46 StoragesDistributed 47 48 GUIApplication 49 } 50 51 // ApplicationEngine is the interface that return some useful data about the engine that implement Application protocol 52 // In many ways it is like window.navigator in web ecosystem 53 type ApplicationEngine interface { 54 Name() string 55 CharacterSet() string 56 } 57 58 // ApplicationManifest is the interface that must implement by any Application. 59 type ApplicationManifest interface { 60 Icon() []byte 61 DomainName() string 62 Email() string 63 64 UserUUID() (userUUID [32]byte) 65 UserID() (userID uint32) 66 AppUUID() (appUUID [32]byte) 67 AppID() (appID uint16) // local OS application ID 68 69 ContentPreferences() 70 PresentationPreferences() 71 } 72 73 // ApplicationState indicate application state 74 // Force to use 32 bit length due to it is minimum atomic helper functions size. 75 type ApplicationState uint32 76 77 // Application State 78 const ( 79 ApplicationState_Unset ApplicationState = iota // State not set yet! 80 ApplicationState_Starting // plan to start 81 ApplicationState_Running 82 ApplicationState_Stopping 83 ApplicationState_Stopped 84 85 ApplicationState_PowerFailure 86 87 ApplicationState_Stable 88 ApplicationState_NotResponse 89 90 ApplicationState_Splitting 91 ApplicationState_ReAllocate 92 // ApplicationState_AcceptWrite 93 )