mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Federation sender API remodel (#988)
* Define an input API for the federationsender * Wiring for rooomserver input API and federation sender input API * Whoops, commit common too * Merge input API into query API * Rename FederationSenderQueryAPI to FederationSenderInternalAPI * Fix dendritejs * Rename Input to Perform * Fix a couple of inputs -> performs * Remove needless storage interface, add comments
This commit is contained in:
parent
a4b9edb28e
commit
a308e61331
23 changed files with 293 additions and 136 deletions
53
federationsender/api/api.go
Normal file
53
federationsender/api/api.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// FederationSenderInternalAPI is used to query information from the federation sender.
|
||||
type FederationSenderInternalAPI interface {
|
||||
// Query the joined hosts and the membership events accounting for their participation in a room.
|
||||
// Note that if a server has multiple users in the room, it will have multiple entries in the returned slice.
|
||||
// See `QueryJoinedHostServerNamesInRoom` for a de-duplicated version.
|
||||
QueryJoinedHostsInRoom(
|
||||
ctx context.Context,
|
||||
request *QueryJoinedHostsInRoomRequest,
|
||||
response *QueryJoinedHostsInRoomResponse,
|
||||
) error
|
||||
// Query the server names of the joined hosts in a room.
|
||||
// Unlike QueryJoinedHostsInRoom, this function returns a de-duplicated slice
|
||||
// containing only the server names (without information for membership events).
|
||||
QueryJoinedHostServerNamesInRoom(
|
||||
ctx context.Context,
|
||||
request *QueryJoinedHostServerNamesInRoomRequest,
|
||||
response *QueryJoinedHostServerNamesInRoomResponse,
|
||||
) error
|
||||
// Handle an instruction to make_join & send_join with a remote server.
|
||||
PerformJoinRequest(
|
||||
ctx context.Context,
|
||||
request *PerformJoinRequest,
|
||||
response *PerformJoinResponse,
|
||||
) error
|
||||
// Handle an instruction to make_leave & send_leave with a remote server.
|
||||
PerformLeaveRequest(
|
||||
ctx context.Context,
|
||||
request *PerformLeaveRequest,
|
||||
response *PerformLeaveResponse,
|
||||
) error
|
||||
}
|
||||
|
||||
// NewFederationSenderInternalAPIHTTP creates a FederationSenderInternalAPI implemented by talking to a HTTP POST API.
|
||||
// If httpClient is nil an error is returned
|
||||
func NewFederationSenderInternalAPIHTTP(federationSenderURL string, httpClient *http.Client) (FederationSenderInternalAPI, error) {
|
||||
if httpClient == nil {
|
||||
return nil, errors.New("NewFederationSenderInternalAPIHTTP: httpClient is <nil>")
|
||||
}
|
||||
return &httpFederationSenderInternalAPI{federationSenderURL, httpClient}, nil
|
||||
}
|
||||
|
||||
type httpFederationSenderInternalAPI struct {
|
||||
federationSenderURL string
|
||||
httpClient *http.Client
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue