// NewFSSyncTarget allows writing into an io.WriteCloser
347748
func NewFSSyncTarget(w io.WriteCloser) session.Attachable {
	p := &fsSyncTarget{
		outfile: w,
	}
	return p
}
258075
func NewNFSAPI(client *Client) *NFSAPI {
	return &NFSAPI{
		&baseAPI{
			client: client,
			FuncGetResourceURL: func() string {
				return "appliance"
			},
			FuncBaseSearchCondition: func() *sacloud.Request {
				res := &sacloud.Request{}
				res.AddFilter("Class", "nfs")
				return res
			},
		},
	}
}
913512
func NewClient(cfg *Config) (client *Client, err error) {
	db, err := bolt.Open(cfg.DbPath, cfg.FileMode, &bolt.Options{
		Timeout: cfg.LockTimeout,
	})
	if err != nil {
		return nil, err
	}
	boltLogger.Infof("bolt path: %v", db.Path())

	err = db.Update(func(tx *bolt.Tx) error {
		_, err := tx.CreateBucketIfNotExists(rootBucket)
		return err
	})
	if err != nil {
		return nil, err
	}

	c := &Client{
		db:         db,
		cfg:        *cfg,
		quit:       make(chan struct{}),
		updateChan: make(chan *updateTx, UpdatesChannelSize),
	}

	c.wg.Add(1)
	go c.startUpdater()

	return c, nil
}
878314
func filterTargets(
	wcs []io.WriteCloser,
	line []byte,
	filter func(io.WriteCloser, []byte) bool,
) []io.WriteCloser {
	var filteredTargets []io.WriteCloser

	for _, c := range wcs {
		if !filter(c, line) {
			filteredTargets = append(filteredTargets, c)
		}
	}
	return filteredTargets
}
135913
func newExternalClusterClient(endpoint, token, caFilePath string) (*clientWrapper, error) {
	if endpoint == "" {
		return nil, errors.New("endpoint missing for external cluster client")
	}

	config := &rest.Config{
		Host:        endpoint,
		BearerToken: token,
	}

	if caFilePath != "" {
		caData, err := ioutil.ReadFile(caFilePath)
		if err != nil {
			return nil, fmt.Errorf("failed to read CA file %s: %s", caFilePath, err)
		}

		config.TLSClientConfig = rest.TLSClientConfig{CAData: caData}
	}
	return createClientFromConfig(config)
}
719034
func NewActivateTargetArgs(targetID ID) *ActivateTargetArgs {
	args := new(ActivateTargetArgs)
	args.TargetID = targetID
	return args
}
537417
func (bb *Builder) SetSymlinkTarget(target string) *Builder {
	bb.SetType("symlink")
	if utf8.ValidString(target) {
		bb.m["symlinkTarget"] = target
	} else {
		bb.m["symlinkTargetBytes"] = mixedArrayFromString(target)
	}
	return bb
}
165331
func NewFS(ctx context.Context, config libkbfs.Config, log logger.Logger) (*FS, error) {
	if currentUserSIDErr != nil {
		return nil, currentUserSIDErr
	}
	quLog := config.MakeLogger(libkbfs.QuotaUsageLogModule("FS"))
	f := &FS{
		config:        config,
		log:           log,
		vlog:          config.MakeVLogger(log),
		notifications: libfs.NewFSNotifications(log),
		quotaUsage: libkbfs.NewEventuallyConsistentQuotaUsage(
			config, quLog, config.MakeVLogger(quLog)),
	}

	f.root = &Root{
		private: &FolderList{
			fs:         f,
			tlfType:    tlf.Private,
			folders:    make(map[string]fileOpener),
			aliasCache: map[string]string{},
		},
		public: &FolderList{
			fs:         f,
			tlfType:    tlf.Public,
			folders:    make(map[string]fileOpener),
			aliasCache: map[string]string{},
		},
		team: &FolderList{
			fs:         f,
			tlfType:    tlf.SingleTeam,
			folders:    make(map[string]fileOpener),
			aliasCache: map[string]string{},
		}}

	ctx = wrapContext(ctx, f)

	f.remoteStatus.Init(ctx, f.log, f.config, f)
	f.notifications.LaunchProcessor(ctx)
	go clearFolderListCacheLoop(ctx, f.root)

	return f, nil
}
820384
func (d *domainClient) CreateTarget(ctx context.Context, args *CreateTargetArgs) (reply *CreateTargetReply, err error) {
	reply = new(CreateTargetReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Target.createTarget", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Target.createTarget", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Target", Op: "CreateTarget", Err: err}
	}
	return
}
879090
func NewFSock(fsaddr, fspaswd string, reconnects int, eventHandlers map[string][]func(string, string), eventFilters map[string][]string, l *syslog.Writer, connId string) (fsock *FSock, err error) {
	fsock = &FSock{
		fsMutex:         new(sync.RWMutex),
		connId:          connId,
		fsaddress:       fsaddr,
		fspaswd:         fspaswd,
		eventHandlers:   eventHandlers,
		eventFilters:    eventFilters,
		backgroundChans: make(map[string]chan string),
		cmdChan:         make(chan string),
		reconnects:      reconnects,
		delayFunc:       DelayFunc(),
		logger:          l,
	}
	if err = fsock.Connect(); err != nil {
		return nil, err
	}
	return
}
425824
func newAzureWriteCloser(ctx context.Context, f *FS, obj *object) io.WriteCloser {
	pr, pw := io.Pipe()
	bw := bufio.NewWriter(pw)

	g, _ := errgroup.WithContext(ctx)

	g.Go(func() error {
		// Upload the file to azure.
		// Do a multipart upload
		err := f.uploadMultiPart(obj, pr)
		if err != nil {
			gou.Warnf("could not upload %v", err)
			return err
		}
		return nil
	})

	return azureWriteCloser{
		pr, pw, bw, g,
	}
}
1169472
func NewFSFileContentProvider(root string, driver driver.Driver) FileContentProvider {
	return &fsContentProvider{
		root:   root,
		driver: driver,
	}
}
7833
func NewCreateFileRequestArgs(Title string, Destination string) *CreateFileRequestArgs {
	s := new(CreateFileRequestArgs)
	s.Title = Title
	s.Destination = Destination
	s.Open = true
	return s
}
805896
func NewNSQTarget(id string, args NSQArgs) (*NSQTarget, error) {
	config := nsq.NewConfig()
	if args.TLS.Enable {
		config.TlsV1 = true
		config.TlsConfig = &tls.Config{
			InsecureSkipVerify: args.TLS.SkipVerify,
		}
	}
	producer, err := nsq.NewProducer(args.NSQDAddress.String(), config)

	if err != nil {
		return nil, err
	}

	return &NSQTarget{
		id:       event.TargetID{ID: id, Name: "nsq"},
		args:     args,
		producer: producer,
	}, nil
}
205749
func NewClient(st base.APICallCloser) (*Client, error) {
	frontend, backend := base.NewClientFacade(st, "Backups")
	client, err := st.HTTPClient()
	if err != nil {
		return nil, errors.Trace(err)
	}
	return MakeClient(frontend, backend, client), nil
}
707874
func (conn *BytesConnectionStr) NewAsyncPublisher(topic string, successClb func(*client.ProducerMessage), errorClb func(err *client.ProducerError)) (BytesPublisher, error) {
	return &bytesAsyncPublisherKafka{conn, topic, successClb, errorClb}, nil
}
1308668
func (ix *Reindexer) TargetClient(c *Client) *Reindexer {
	ix.targetClient = c
	return ix
}