base

package
v0.0.0-...-811715e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const HTTPClientTimeout = time.Second * 30
View Source
const HTTPServerTimeout = time.Minute * 5
View Source
const NoListener = ""

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseDendrite

type BaseDendrite struct {
	*process.ProcessContext

	PublicClientAPIMux     *mux.Router
	PublicFederationAPIMux *mux.Router
	PublicKeyAPIMux        *mux.Router
	PublicMediaAPIMux      *mux.Router
	PublicWellKnownAPIMux  *mux.Router
	InternalAPIMux         *mux.Router
	DendriteAdminMux       *mux.Router
	SynapseAdminMux        *mux.Router
	NATS                   *jetstream.NATSInstance
	UseHTTPAPIs            bool

	Cfg            *config.Dendrite
	Caches         *caching.Caches
	DNSCache       *gomatrixserverlib.DNSCache
	Database       *sql.DB
	DatabaseWriter sqlutil.Writer
	EnableMetrics  bool
	Fulltext       *fulltext.Search
	// contains filtered or unexported fields
}

BaseDendrite is a base for creating new instances of dendrite. It parses command line flags and config, and exposes methods for creating various resources. All errors are handled by logging then exiting, so all methods should only be used during start up. Must be closed when shutting down.

func NewBaseDendrite

func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...BaseDendriteOptions) *BaseDendrite

NewBaseDendrite creates a new instance to be used by a component. The componentName is used for logging purposes, and should be a friendly name of the compontent running, e.g. "SyncAPI"

func (*BaseDendrite) AppserviceHTTPClient

func (b *BaseDendrite) AppserviceHTTPClient() appserviceAPI.AppServiceInternalAPI

AppserviceHTTPClient returns the AppServiceInternalAPI for hitting the appservice component over HTTP.

func (*BaseDendrite) Close

func (b *BaseDendrite) Close() error

Close implements io.Closer

func (*BaseDendrite) CreateClient

func (b *BaseDendrite) CreateClient() *gomatrixserverlib.Client

CreateClient creates a new client (normally used for media fetch requests). Should only be called once per component.

func (*BaseDendrite) CreateFederationClient

func (b *BaseDendrite) CreateFederationClient() *gomatrixserverlib.FederationClient

CreateFederationClient creates a new federation client. Should only be called once per component.

func (*BaseDendrite) DatabaseConnection

func (b *BaseDendrite) DatabaseConnection(dbProperties *config.DatabaseOptions, writer sqlutil.Writer) (*sql.DB, sqlutil.Writer, error)

DatabaseConnection assists in setting up a database connection. It accepts the database properties and a new writer for the given component. If we're running in monolith mode with a global connection pool configured then we will return that connection, along with the global writer, effectively ignoring the options provided. Otherwise we'll open a new database connection using the supplied options and writer. Note that it's possible for the pointer receiver to be nil here – that's deliberate as some of the unit tests don't have a BaseDendrite and just want a connection with the supplied config without any pooling stuff.

func (*BaseDendrite) FederationAPIHTTPClient

func (b *BaseDendrite) FederationAPIHTTPClient() federationAPI.FederationInternalAPI

FederationAPIHTTPClient returns FederationInternalAPI for hitting the federation API server over HTTP

func (*BaseDendrite) KeyServerHTTPClient

func (b *BaseDendrite) KeyServerHTTPClient() keyserverAPI.KeyInternalAPI

KeyServerHTTPClient returns KeyInternalAPI for hitting the key server over HTTP

func (*BaseDendrite) PushGatewayHTTPClient

func (b *BaseDendrite) PushGatewayHTTPClient() pushgateway.Client

PushGatewayHTTPClient returns a new client for interacting with (external) Push Gateways.

func (*BaseDendrite) RoomserverHTTPClient

func (b *BaseDendrite) RoomserverHTTPClient() roomserverAPI.RoomserverInternalAPI

RoomserverHTTPClient returns RoomserverInternalAPI for hitting the roomserver over HTTP.

func (*BaseDendrite) SetupAndServeHTTP

func (b *BaseDendrite) SetupAndServeHTTP(
	internalHTTPAddr, externalHTTPAddr config.HTTPAddress,
	certFile, keyFile *string,
)

SetupAndServeHTTP sets up the HTTP server to serve endpoints registered on ApiMux under /api/ and adds a prometheus handler under /metrics.

func (*BaseDendrite) UserAPIClient

func (b *BaseDendrite) UserAPIClient() userapi.UserInternalAPI

UserAPIClient returns UserInternalAPI for hitting the userapi over HTTP.

func (*BaseDendrite) WaitForShutdown

func (b *BaseDendrite) WaitForShutdown()

type BaseDendriteOptions

type BaseDendriteOptions int
const (
	DisableMetrics BaseDendriteOptions = iota
	UseHTTPAPIs
	PolylithMode
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL