// NewSerialPort returns a new serial over Bluetooth LE connection
352650
func NewSerialPort(address string, rid string, tid string) *SerialPort {
	return &SerialPort{address: address, rid: rid, tid: tid}
}
1125621
func (t *ChannelTransport) NewSingleOutbound(addr string) *ChannelOutbound {
	return &ChannelOutbound{
		once:      lifecycle.NewOnce(),
		channel:   t.ch,
		transport: t,
		addr:      addr,
	}
}
31946
func NewService(cargos cargo.Repository, locations location.Repository, events cargo.HandlingEventRepository, rs routing.Service) Service {
	return &service{
		cargos:         cargos,
		locations:      locations,
		handlingEvents: events,
		routingService: rs,
	}
}
364397
func NewStatsFetcher(logger log.Logger, pool *pool.ConnPool, region string) *StatsFetcher {
	return &StatsFetcher{
		logger:   logger.Named("stats_fetcher"),
		pool:     pool,
		region:   region,
		inflight: make(map[string]struct{}),
	}
}
328397
func restAddPort(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
	glog.V(1).Infof("Add PORT with %s %#v", r.URL.Path, r)

	serviceid, application, port, err := getPortContext(r)
	if err != nil {
		err := fmt.Errorf("Error removing port from service (%s): %v", serviceid, err)
		glog.Error(err)
		restServerError(w, err)
		return
	}

	var request endpointRequest
	err = r.DecodeJsonPayload(&request)
	if err != nil {
		restBadRequest(w, err)
		return
	}

	glog.V(0).Infof("Add PORT with %s %#v", r.URL.Path, r)

	facade := ctx.getFacade()
	dataCtx := ctx.getDatastoreContext()

	_, err = facade.AddPublicEndpointPort(dataCtx, serviceid, application,
		port, request.UseTLS, request.Protocol, true, true)
	if err != nil {
		glog.Errorf("Error adding port to service (%s): %v", request.ServiceName, err)
		restServerError(w, err)
		return
	}

	glog.V(2).Infof("Port (%s) added to service (%s), UseTLS=%s, protocol=%s",
		port, request.ServiceName, request.UseTLS, request.Protocol)

	restSuccess(w)
}
1142018
func portForServicePort(svc *service.Service, portStr string, pType string) *service.Port {
	// Look up the ServicePort and translate to Docker port
	svcPort, err := strconv.ParseInt(portStr, 10, 64)
	if err != nil {
		log.Warnf(
			"SidecarListener label found on %s, can't decode port '%s'",
			svc.ID, portStr,
		)
		return nil
	}

	for _, port := range svc.Ports {
		if port.ServicePort == svcPort && port.Type == pType {
			return &port
		}
	}

	return nil
}
210887
func (c *Client) NewSnapshot(opts *NewSnapshotOptions) (NewSnapshotResult, error) {
	req := xms.PostSnapshotsReq(*opts)
	return c.api.PostSnapshots(&req)
}
1178688
func updateServiceLastReported(ds models.DeviceService, lr int64, w http.ResponseWriter) error {
	ds.LastReported = lr
	if err := dbClient.UpdateDeviceService(ds); err != nil {
		http.Error(w, err.Error(), http.StatusServiceUnavailable)
		return err
	}

	return nil
}
341676
func NewSenderWithHTTPClient(apiKey string, client *http.Client) *Sender {
	return &Sender{apiKey, client}
}
814567
func NewServicedStatsReporter(destination string, interval time.Duration, conn coordclient.Connection, dockerClient docker.Docker) (*ServicedStatsReporter, error) {
	hostID, err := utils.HostID()
	if err != nil {
		plog.WithError(err).Debug("Could not determine host ID")
		return nil, err
	}
	if conn == nil {
		plog.Debug("Received empty coordinator client connection")
		return nil, fmt.Errorf("Coordinator client connection does not exist")
	}
	ssr := ServicedStatsReporter{
		statsReporter: statsReporter{
			destination:  destination,
			closeChannel: make(chan struct{}),
		},
		hostID:              hostID,
		previousStats:       make(map[string]map[string]uint64),
		conn:                conn,
		containerRegistries: make(map[registryKey]metrics.Registry),
		docker:              dockerClient,
	}

	ssr.hostRegistry = metrics.NewRegistry()
	ssr.statsReporter.updateStatsFunc = ssr.updateStats
	ssr.statsReporter.gatherStatsFunc = ssr.gatherStats
	go ssr.report(interval)
	return &ssr, nil
}
1277571
func (res *Resource) NewStruct() interface{} {
	if res.Value == nil {
		return nil
	}
	return reflect.New(utils.Indirect(reflect.ValueOf(res.Value)).Type()).Interface()
}
188890
func (p *SerialPort) Open() (err error) {
	p.client = NewClientAdaptor(p.address)

	err = p.client.Connect()

	// subscribe to response notifications
	p.client.Subscribe(p.rid, func(data []byte, e error) {
		p.responseMutex.Lock()
		p.responseData = append(p.responseData, data...)
		p.responseMutex.Unlock()
	})
	return
}
413540
func NewStrictDecodingError(message string, data string) error {
	return &strictDecodingError{
		message: message,
		data:    data,
	}
}
250226
func NewSPDYExecutorForTransports(transport http.RoundTripper, upgrader spdy.Upgrader, method string, url *url.URL) (Executor, error) {
	return NewSPDYExecutorForProtocols(
		transport, upgrader, method, url,
		remotecommand.StreamProtocolV4Name,
		remotecommand.StreamProtocolV3Name,
		remotecommand.StreamProtocolV2Name,
		remotecommand.StreamProtocolV1Name,
	)
}
549071
func NewSharedLinkShareType(Description string) *SharedLinkShareType {
	s := new(SharedLinkShareType)
	s.Description = Description
	return s
}
42776
func Serializer(serializer reporter.SpanSerializer) ReporterOption {
	return func(c *kafkaReporter) {
		if serializer != nil {
			c.serializer = serializer
		}
	}
}
1301159
func NewSharedContentChangeInviteeRoleType(Description string) *SharedContentChangeInviteeRoleType {
	s := new(SharedContentChangeInviteeRoleType)
	s.Description = Description
	return s
}