github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/service.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package protocol 4 5 // Services is the interface that must implement by any Application! 6 type Services interface { 7 // RegisterService use to register application services. 8 // Due to minimize performance impact, This method isn't safe to use concurrently and 9 // must register all service before use GetService methods. 10 RegisterService(s Service) 11 12 GetServiceByID(mtID uint64) (ser Service, err Error) 13 GetServiceByMediaType(mt string) (ser Service, err Error) 14 GetServiceByURI(uri string) (ser Service, err Error) 15 } 16 17 // Service is the interface that must implement by any struct to be a service! 18 // Set fields methods in this type must accept just once to prevent any mistake by change after set first! 19 type Service interface { 20 // Request() MediaType 21 // Response() MediaType 22 URI() string // HTTPURI.Path 23 24 Priority() Priority // Use to queue requests by its priority 25 Weight() Weight // Use to queue requests by its weights in the same priority 26 27 // Service Authorization 28 CRUDType() CRUD 29 UserType() UserType 30 31 // Handlers, Due to specific args and returns, we can't uncomment some of them 32 // Handle(st Stream, req interface{}) (res interface{}, err Error) Call service locally by import service package to other one 33 SRPCHandler 34 HTTPHandler // Some other protocol like gRPC, SOAP, ... must implement inside HTTP, If they are use HTTP as a transfer protocol. 35 // Do(req interface{}) (res interface{}, err Error) Call service remotely by preferred protocol. 36 // DoSRPC(req interface{}) (res interface{}, err Error) Call service remotely by sRPC protocol 37 // DoHTTP(req interface{}) (res interface{}, err Error) Call service remotely by HTTP protocol 38 39 MediaType 40 }