// PublishRaw indicates an expected call of PublishRaw
544429
func (mr *MockConnectorMockRecorder) PublishRaw(target, data interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishRaw", reflect.TypeOf((*MockConnector)(nil).PublishRaw), target, data)
}
856939
func Publish(ctx context.Context, topic string, msg proto.Message) *PublishResult {
	pr := &PublishResult{Ready: make(chan struct{})}
	go func() {
		err := client.Publish(ctx, topic, msg, false)
		pr.Err = err
		close(pr.Ready)
	}()
	return pr
}
1173937
func (c *Client) processPublish(publish *packet.Publish) error {
	// handle qos 0 flow
	if publish.Message.QOS == 0 {
		// publish message
		err := c.backend.Publish(c, &publish.Message, nil)
		if err != nil {
			return c.die(BackendError, err)
		}

		c.backend.Log(MessagePublished, c, nil, &publish.Message, nil)

		return nil
	}

	// acquire publish token
	select {
	case <-c.publishTokens:
		// continue
	case <-time.After(c.TokenTimeout):
		return c.die(ClientError, ErrTokenTimeout)
	case <-c.tomb.Dying():
		return tomb.ErrDying
	}

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

		// publish message and queue puback if ack is called
		err := c.backend.Publish(c, &publish.Message, func() {
			c.backend.Log(MessageAcknowledged, c, nil, &publish.Message, nil)

			select {
			case c.ackQueue <- puback:
			case <-c.tomb.Dying():
			}
		})
		if err != nil {
			return c.die(BackendError, err)
		}

		c.backend.Log(MessagePublished, c, nil, &publish.Message, nil)
	}

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

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

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

	return nil
}
315503
func (mr *MockPublishableConnectorMockRecorder) Publish(msg interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Publish", reflect.TypeOf((*MockPublishableConnector)(nil).Publish), msg)
}
1201226
func (e *Events) PublishMessage(jm eventtypes.Message) {
	eventsCounter.Inc()

	e.mu.Lock()
	if len(e.events) == cap(e.events) {
		// discard oldest event
		copy(e.events, e.events[1:])
		e.events[len(e.events)-1] = jm
	} else {
		e.events = append(e.events, jm)
	}
	e.mu.Unlock()
	e.pub.Publish(jm)
}
411866
func (nc *Conn) PublishRequest(subj, reply string, data []byte) error {
	return nc.publish(subj, reply, data)
}
1231315
func (s *Service) PublishMessage(msg *packet.Message) GenericFuture {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	// allocate future
	f := future.New()

	// queue publish
	s.commandQueue <- &command{
		publish: true,
		future:  f,
		message: msg,
	}

	return f
}
989607
func (e *Engine) ExecuteRaw(src string, wr io.Writer, binding interface{}) (err error) {
	parsed := blackfriday.MarkdownCommon([]byte(src))
	if e.Config.Sanitize {
		parsed = bluemonday.UGCPolicy().SanitizeBytes(parsed)
	}
	_, err = wr.Write(parsed)
	return
}
858665
func (Pipe) Publish(ctx *context.Context) error {
	snaps := ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List()
	var g = semerrgroup.New(ctx.Parallelism)
	for _, snap := range snaps {
		snap := snap
		g.Go(func() error {
			return push(ctx, snap)
		})
	}
	return g.Wait()
}
1232642
func (e *Engine) ExecuteRaw(src string, wr io.Writer, binding interface{}) (err error) {
	tmpl, err := raymond.Parse(src)
	if err != nil {
		return err
	}
	parsed, err := tmpl.Exec(binding)
	if err != nil {
		return err
	}
	_, err = wr.Write([]byte(parsed))
	return
}
118704
func (s Session) AddRaw(k rune, v string) Session {
	return s.appendString(Type(k), v)
}
190568
func (pcc *PubControlClient) Publish(channel string, item *Item) error {
	return pcc.publish(pcc, channel, item)
}
633465
func (o *pubSubOutput) publishMessage(message *pubsub.Message) error {
	var messageID string
	transientErrors := 0
	err := retry.Retry(o, transient.Only(indefiniteRetry), func() (err error) {
		ctx := o.Context
		if o.RPCTimeout > 0 {
			var cancelFunc context.CancelFunc
			ctx, cancelFunc = clock.WithTimeout(o, o.RPCTimeout)
			defer cancelFunc()
		}

		messageID, err = o.Topic.Publish(ctx, message)
		if err == context.DeadlineExceeded {
			// If we hit our publish deadline, retry.
			err = transient.Tag.Apply(err)
		} else {
			err = grpcutil.WrapIfTransient(err)
		}
		return
	}, func(err error, d time.Duration) {
		log.Fields{
			log.ErrorKey: err,
			"delay":      d,
		}.Warningf(o, "TRANSIENT error publishing messages; retrying...")
		transientErrors++
	})
	if err != nil {
		log.WithError(err).Errorf(o, "Failed to send PubSub message.")
		return err
	}

	if transientErrors > 0 {
		// We successfully published, but we hit a transient error, so explicitly
		// acknowledge this at warning-level for log message closure.
		log.Fields{
			"messageId":       messageID,
			"transientErrors": transientErrors,
		}.Warningf(o, "Successfully published messages after transient errors.")
	} else {
		log.Fields{
			"messageId": messageID,
		}.Debugf(o, "Published messages.")
	}
	return nil
}
782170
func PublishAsync(topic string, body []byte, doneChan chan *nsq.ProducerTransaction, args ...interface{}) error {
	return DefaultProducer.PublishAsync(topic, body, doneChan, args...)
}
681200
func (c *DefaultClient) PublishDeviceEvent(appID string, devID string, eventType types.EventType, payload interface{}) Token {
	topic := DeviceTopic{appID, devID, DeviceEvents, string(eventType)}
	msg, err := json.Marshal(payload)
	if err != nil {
		return &simpleToken{fmt.Errorf("Unable to marshal the message payload: %s", err)}
	}
	return c.publish(topic.String(), msg)
}
534536
func (p *Publisher) Publish(pub amqp.Publishing) error {
	return p.PublishWithRoutingKey(pub, p.key)
}
687243
func (queue *redisQueue) Publish(payload string) bool {
	// debug(fmt.Sprintf("publish %s %s", payload, queue)) // COMMENTOUT
	return queue.redisClient.LPush(queue.readyKey, payload)
}