// NewPublisher returns a pointer to a new Publisher instance.
19217
func NewPublisher(etcdHost string, etcdPort int, etcdPath string, publishInterval int,
	publishTTL int, logHost string, logPort int) (*Publisher, error) {
	etcdClient := etcd.NewClient([]string{fmt.Sprintf("http://%s:%d", etcdHost, etcdPort)})
	ticker := time.NewTicker(time.Duration(publishInterval) * time.Second)
	return &Publisher{
		etcdClient: etcdClient,
		etcdPath:   etcdPath,
		publishTTL: uint64(time.Duration(publishTTL) * time.Second),
		logHost:    logHost,
		logPort:    logPort,
		ticker:     ticker,
	}, nil
}
1000164
func NewReader(buf []byte, simple bool) (reader *Reader) {
	reader = new(Reader)
	reader.buf = buf
	reader.Simple = simple
	return
}
1230498
func NewRawReader(buf []byte) (reader *RawReader) {
	reader = new(RawReader)
	reader.buf = buf
	return
}
1004763
func newPublicationTracker(pub publicationDescriptor, profile *StatsProfile) *tracker {
	return &tracker{
		profile:     profile,
		reqService:  "micro.pubsub",
		reqEndpoint: pub.Topic(),
	}
}
159923
func MultiPublish(topic string, body [][]byte) error {
	return DefaultProducer.MultiPublish(topic, body)
}
522625
func NewOOMEpoller(publisher shim.Publisher) (*Epoller, error) {
	fd, err := unix.EpollCreate1(unix.EPOLL_CLOEXEC)
	if err != nil {
		return nil, err
	}
	return &Epoller{
		fd:        fd,
		publisher: publisher,
		set:       make(map[uintptr]*item),
	}, nil
}
967277
func NewPeer(p *p2p.Peer, rw p2p.MsgReadWriter, spec *Spec) *Peer {
	return &Peer{
		Peer: p,
		rw:   rw,
		spec: spec,
	}
}
689572
func (c *Client) processPublish(publish *packet.Publish) error {
	// call callback for unacknowledged and directly acknowledged messages
	if publish.Message.QOS <= 1 {
		if c.Callback != nil {
			err := c.Callback(&publish.Message, nil)
			if err != nil {
				return c.die(err, true, true)
			}
		}
	}

	// handle qos 1 flow
	if publish.Message.QOS == 1 {
		// prepare puback packet
		puback := packet.NewPuback()
		puback.ID = publish.ID

		// acknowledge qos 1 publish
		err := c.send(puback, true)
		if err != nil {
			return c.die(err, false, false)
		}
	}

	// handle qos 2 flow
	if publish.Message.QOS == 2 {
		// store packet
		err := c.Session.SavePacket(session.Incoming, publish)
		if err != nil {
			return c.die(err, true, false)
		}

		// prepare pubrec packet
		pubrec := packet.NewPubrec()
		pubrec.ID = publish.ID

		// acknowledge qos 2 publish
		err = c.send(pubrec, true)
		if err != nil {
			return c.die(err, false, false)
		}
	}

	return nil
}
687342
func newReader(ctx context.Context, d *dispatcher, r io.ReadCloser) *reader {
	return &reader{
		ctx: ctx,
		d:   d,
		r:   r,
	}
}
372009
func IsPublishableModel(model interface{}) (ok bool) {
	if model != nil {
		_, ok = reflect.New(utils.ModelType(model)).Interface().(publishInterface)
	}
	return
}
851447
func NewPublisher(cmInformer coreinformers.ConfigMapInformer, nsInformer coreinformers.NamespaceInformer, cl clientset.Interface, rootCA []byte) (*Publisher, error) {
	e := &Publisher{
		client: cl,
		rootCA: rootCA,
		queue:  workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "root_ca_cert_publisher"),
	}
	if cl.CoreV1().RESTClient().GetRateLimiter() != nil {
		if err := metrics.RegisterMetricAndTrackRateLimiterUsage("root_ca_cert_publisher", cl.CoreV1().RESTClient().GetRateLimiter()); err != nil {
			return nil, err
		}
	}

	cmInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		DeleteFunc: e.configMapDeleted,
		UpdateFunc: e.configMapUpdated,
	})
	e.cmLister = cmInformer.Lister()
	e.cmListerSynced = cmInformer.Informer().HasSynced

	nsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc:    e.namespaceAdded,
		UpdateFunc: e.namespaceUpdated,
	})
	e.nsListerSynced = nsInformer.Informer().HasSynced

	e.syncHandler = e.syncNamespace

	return e, nil

}
693618
func NewPublicNamer(prependPackageNames int, ignoreWords ...string) *NameStrategy {
	n := &NameStrategy{
		Join:                Joiner(IC, IC),
		IgnoreWords:         map[string]bool{},
		PrependPackageNames: prependPackageNames,
	}
	for _, w := range ignoreWords {
		n.IgnoreWords[w] = true
	}
	return n
}
693633
func NewPublisher(
	ch Channel,
	q *amqp.Queue,
	enc EncodeRequestFunc,
	dec DecodeResponseFunc,
	options ...PublisherOption,
) *Publisher {
	p := &Publisher{
		ch:        ch,
		q:         q,
		enc:       enc,
		dec:       dec,
		deliverer: DefaultDeliverer,
		timeout:   10 * time.Second,
	}
	for _, option := range options {
		option(p)
	}
	return p
}
711352
func (e *JSONEncoder) EncodePublish(res *PublishResult) ([]byte, error) {
	return json.Marshal(res)
}
1001051
func NewPUBLISHFromBytes(fixedHeader FixedHeader, remaining []byte) (Packet, error) {
	// Validate the byte data.
	if err := validatePUBLISHBytes(fixedHeader, remaining); err != nil {
		return nil, err
	}

	// Get the first byte from the fixedHeader.
	b := fixedHeader[0]

	// Create a PUBLISH Packet.
	p := &PUBLISH{
		DUP:    b&0x08 == 0x08,
		QoS:    b & 0x06 >> 1,
		retain: b&0x01 == 0x01,
	}

	// Set the fixed header to the Packet.
	p.fixedHeader = fixedHeader

	// Extract the length of the Topic Name.
	lenTopicName, _ := decodeUint16(remaining[0:2])

	// Calculate the length of the variable header.
	var lenVariableHeader int

	if p.QoS == mqtt.QoS0 {
		lenVariableHeader = 2 + int(lenTopicName)
	} else {
		lenVariableHeader = 2 + int(lenTopicName) + 2
	}

	// Set the variable header to the Packet.
	p.variableHeader = remaining[:lenVariableHeader]

	// Set the payload to the Packet.
	p.payload = remaining[lenVariableHeader:]

	// Set the Topic Name to the Packet.
	p.TopicName = remaining[2 : 2+lenTopicName]

	// Extract the Packet Identifier.
	var packetID uint16

	if p.QoS != mqtt.QoS0 {
		packetID, _ = decodeUint16(remaining[2+lenTopicName : 2+lenTopicName+2])
	}

	// Set the Packet Identifier to the Packet.
	p.PacketID = packetID

	// Set the Application Message to the Packet.
	p.Message = p.payload

	// Return the Packet.
	return p, nil
}
301716
func NewReader(r io.Reader) *Reader {
	nr := Reader{}
	nr.r = r
	return &nr
}
919382
function createPublisher(broker, configurator) {
    var params = getParams(PublisherConfiguration, configurator);
    return Publisher(broker, params.envelope, params.pipeline, params.routeName, params.routePattern, params.logger);
  }