mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Move buffer/httpclient pools to pool package.
This commit is contained in:
parent
5543046305
commit
25e040ffb9
11 changed files with 28 additions and 15 deletions
|
|
@ -50,6 +50,10 @@ component_management:
|
|||
name: nats
|
||||
paths:
|
||||
- nats/**
|
||||
- component_id: module_pool
|
||||
name: pool
|
||||
paths:
|
||||
- pool/**
|
||||
- component_id: module_proxy
|
||||
name: proxy
|
||||
paths:
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ import (
|
|||
"github.com/dlintw/goconf"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotRedirecting = errors.New("not redirecting to different host")
|
||||
ErrUnsupportedContentType = errors.New("unsupported_content_type")
|
||||
|
||||
ErrIncompleteResponse = errors.New("incomplete OCS response")
|
||||
|
|
@ -53,9 +53,9 @@ type BackendClient struct {
|
|||
version string
|
||||
backends *BackendConfiguration
|
||||
|
||||
pool *HttpClientPool
|
||||
pool *pool.HttpClientPool
|
||||
capabilities *Capabilities
|
||||
buffers BufferPool
|
||||
buffers pool.BufferPool
|
||||
}
|
||||
|
||||
func NewBackendClient(ctx context.Context, config *goconf.ConfigFile, maxConcurrentRequestsPerHost int, version string, etcdClient *EtcdClient) (*BackendClient, error) {
|
||||
|
|
@ -70,7 +70,7 @@ func NewBackendClient(ctx context.Context, config *goconf.ConfigFile, maxConcurr
|
|||
logger.Println("WARNING: Backend verification is disabled!")
|
||||
}
|
||||
|
||||
pool, err := NewHttpClientPool(maxConcurrentRequestsPerHost, skipverify)
|
||||
pool, err := pool.NewHttpClientPool(maxConcurrentRequestsPerHost, skipverify)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
func returnOCS(t *testing.T, w http.ResponseWriter, body []byte) {
|
||||
|
|
@ -145,7 +146,7 @@ func TestPostOnRedirectDifferentHost(t *testing.T) {
|
|||
err = client.PerformJSONRequest(ctx, u, request, &response)
|
||||
if err != nil {
|
||||
// The redirect to a different host should have failed.
|
||||
require.ErrorIs(err, ErrNotRedirecting)
|
||||
require.ErrorIs(err, pool.ErrNotRedirecting)
|
||||
} else {
|
||||
require.Fail("The redirect should have failed")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import (
|
|||
"github.com/strukturag/nextcloud-spreed-signaling/container"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -83,7 +84,7 @@ type BackendServer struct {
|
|||
statsAllowedIps atomic.Pointer[container.IPList]
|
||||
invalidSecret []byte
|
||||
|
||||
buffers BufferPool
|
||||
buffers pool.BufferPool
|
||||
}
|
||||
|
||||
func NewBackendServer(ctx context.Context, config *goconf.ConfigFile, hub *Hub, version string) (*BackendServer, error) {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -249,16 +250,16 @@ type Capabilities struct {
|
|||
getNow func() time.Time
|
||||
|
||||
version string
|
||||
pool *HttpClientPool
|
||||
pool *pool.HttpClientPool
|
||||
// +checklocks:mu
|
||||
entries map[string]*capabilitiesEntry
|
||||
// +checklocks:mu
|
||||
nextInvalidate map[string]time.Time
|
||||
|
||||
buffers BufferPool
|
||||
buffers pool.BufferPool
|
||||
}
|
||||
|
||||
func NewCapabilities(version string, pool *HttpClientPool) (*Capabilities, error) {
|
||||
func NewCapabilities(version string, pool *pool.HttpClientPool) (*Capabilities, error) {
|
||||
result := &Capabilities{
|
||||
getNow: time.Now,
|
||||
|
||||
|
|
|
|||
|
|
@ -43,12 +43,13 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/api"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
func NewCapabilitiesForTestWithCallback(t *testing.T, callback func(*CapabilitiesResponse, http.ResponseWriter) error) (*url.URL, *Capabilities) {
|
||||
require := require.New(t)
|
||||
assert := assert.New(t)
|
||||
pool, err := NewHttpClientPool(1, false)
|
||||
pool, err := pool.NewHttpClientPool(1, false)
|
||||
require.NoError(err)
|
||||
capabilities, err := NewCapabilities("0.0", pool)
|
||||
require.NoError(err)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import (
|
|||
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/internal"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/log"
|
||||
"github.com/strukturag/nextcloud-spreed-signaling/pool"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -85,7 +86,7 @@ func IsValidCountry(country string) bool {
|
|||
var (
|
||||
InvalidFormat = NewError("invalid_format", "Invalid data format.")
|
||||
|
||||
bufferPool BufferPool
|
||||
bufferPool pool.BufferPool
|
||||
)
|
||||
|
||||
type WritableClientMessage interface {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package signaling
|
||||
package pool
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package signaling
|
||||
package pool
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
|
@ -32,6 +32,10 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotRedirecting = errors.New("not redirecting to different host")
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterHttpClientPoolStats()
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package signaling
|
||||
package pool
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package signaling
|
||||
package pool
|
||||
|
||||
import (
|
||||
"context"
|
||||
Loading…
Add table
Add a link
Reference in a new issue