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