Documentation ¶
Index ¶
- func ConnectGDS(conf config.DirectoryConfig) (_ gds.TRISADirectoryClient, err error)
- func FlattenErrs(in []error) (out []error)
- func FlattenResults(in []proto.Message) (out []proto.Message)
- type RPCFunc
- type Server
- func (s *Server) Available() gin.HandlerFunc
- func (s *Server) GetConf() config.Config
- func (s *Server) GetMainNet() gds.TRISADirectoryClient
- func (s *Server) GetRouter() http.Handler
- func (s *Server) GetTestNet() gds.TRISADirectoryClient
- func (s *Server) GetURL() string
- func (s *Server) Lookup(c *gin.Context)
- func (s *Server) ParallelGDSRequests(ctx context.Context, rpc RPCFunc, flatten bool) (results []proto.Message, errs []error)
- func (s *Server) Register(c *gin.Context)
- func (s *Server) Serve() (err error)
- func (s *Server) SetClients(testnet, mainnet gds.TRISADirectoryClient)
- func (s *Server) SetDB(db *db.DB)
- func (s *Server) SetHealth(health bool)
- func (s *Server) SetURL(url string)
- func (s *Server) Shutdown() (err error)
- func (s *Server) Status(c *gin.Context)
- func (s *Server) TrackPerformance() gin.HandlerFunc
- func (s *Server) VerifyContact(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectGDS ¶
func ConnectGDS(conf config.DirectoryConfig) (_ gds.TRISADirectoryClient, err error)
ConnectGDS creates a gRPC client to the TRISA Directory Service specified in the configuration. This method is used to connect to both the TestNet and the MainNet and to connect to mock GDS services in testing using buffconn.
func FlattenErrs ¶
FlattenErrs removes nil errors from the slice (exported for testing purposes).
Types ¶
type RPCFunc ¶
type RPCFunc func(ctx context.Context, client gds.TRISADirectoryClient, network string) (proto.Message, error)
RPCFunc allows the BFF to issue arbitrary GDS client methods in parallel to both the testnet and the mainnet. The GDS client and network are passed into the function, allowing the RPC to make any GDS RPC call and log with the associated network.
type Server ¶
func (*Server) Available ¶
func (s *Server) Available() gin.HandlerFunc
Available is middleware that uses the healthy boolean to return a service unavailable http status code if the server is shutting down. This middleware must be first in the chain to ensure that complex handling to slow the shutdown of the server.
func (*Server) GetMainNet ¶
func (s *Server) GetMainNet() gds.TRISADirectoryClient
GetMainNet returns the MainNet directory client for testing purposes.
func (*Server) GetTestNet ¶
func (s *Server) GetTestNet() gds.TRISADirectoryClient
GetTestNet returns the TestNet directory client for testing purposes.
func (*Server) GetURL ¶
GetURL returns the URL that the server can be reached if it has been started. This accessor is primarily used to create a test client.
func (*Server) Lookup ¶
Lookup makes a request on behalf of the user to both the TestNet and MainNet GDS servers, returning 1-2 results (e.g. either or both GDS responses). If no results are returned, Lookup returns a 404 not found error. If one of the GDS requests fails, the error is logged, but the valid response is returned. If both GDS requests fail, a 500 error is returned. This endpoint passes through the response from GDS as JSON, the result should contain a registered_directory field that identifies which network the record is associated with.
func (*Server) ParallelGDSRequests ¶
func (s *Server) ParallelGDSRequests(ctx context.Context, rpc RPCFunc, flatten bool) (results []proto.Message, errs []error)
ParallelGDSRequest makes concurrent requests to both the testnet and the mainnet, storing the results and errors in a slice of length 2 ([testnet, mainnet]). If the flatten bool is true, then nil values are removed from the slice (though this will make which network returned the result ambiguous).
func (*Server) Register ¶
Register makes a request on behalf of the user to either the TestNet or the MainNet GDS server based on the URL endpoint. This method is essentially a passthrough conversion of a JSON request to a gRPC request to GDS.
func (*Server) SetClients ¶
func (s *Server) SetClients(testnet, mainnet gds.TRISADirectoryClient)
SetClients allows tests to set a bufconn client to a mock GDS server.
func (*Server) TrackPerformance ¶ added in v1.4.1
func (s *Server) TrackPerformance() gin.HandlerFunc
Middleware that tracks request performance with Sentry.
func (*Server) VerifyContact ¶
VerifyContact is currently a passthrough helper that forwards the verify contact request from the user interface to the GDS that needs contact verification.