-
Notifications
You must be signed in to change notification settings - Fork 725
/
Copy pathcreator.go
46 lines (37 loc) · 884 Bytes
/
creator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/ava-labs/avalanchego/utils/compression"
"github.com/ava-labs/avalanchego/utils/logging"
)
var _ Creator = (*creator)(nil)
type Creator interface {
OutboundMsgBuilder
InboundMsgBuilder
}
type creator struct {
OutboundMsgBuilder
InboundMsgBuilder
}
func NewCreator(
log logging.Logger,
metrics prometheus.Registerer,
compressionType compression.Type,
maxMessageTimeout time.Duration,
) (Creator, error) {
builder, err := newMsgBuilder(
log,
metrics,
maxMessageTimeout,
)
if err != nil {
return nil, err
}
return &creator{
OutboundMsgBuilder: newOutboundBuilder(compressionType, builder),
InboundMsgBuilder: newInboundBuilder(builder),
}, nil
}