schedule

package
v0.2.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2023 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateCmd = &cli.Command{
	Name:      "create",
	Usage:     "Create a schedule to send out deals to a storage provider",
	ArgsUsage: "DATASET_NAME PROVIDER_ID",
	Flags: []cli.Flag{
		&cli.StringSliceFlag{
			Name:     "http-header",
			Category: "Boost Only",
			Aliases:  []string{"H"},
			Usage:    "http headers to be passed with the request (i.e. key=value)",
		},
		&cli.StringFlag{
			Name:     "url-template",
			Category: "Boost Only",
			Aliases:  []string{"u"},
			Usage:    "URL template with PIECE_CID placeholder for boost to fetch the CAR file, i.e. http://127.0.0.1/piece/{PIECE_CID}.car",
			Value:    "",
		},
		&cli.Float64Flag{
			Name:     "price-per-gb-epoch",
			Category: "Deal Proposal",
			Usage:    "Price in FIL per GiB per epoch",
			Value:    0,
		},
		&cli.Float64Flag{
			Name:     "price-per-gb",
			Category: "Deal Proposal",
			Usage:    "Price in FIL  per GiB",
			Value:    0,
		},
		&cli.Float64Flag{
			Name:     "price-per-deal",
			Category: "Deal Proposal",
			Usage:    "Price in FIL per deal",
			Value:    0,
		},
		&cli.BoolFlag{
			Name:     "verified",
			Category: "Deal Proposal",
			Usage:    "Whether to propose deals as verified",
			Value:    true,
		},
		&cli.BoolFlag{
			Name:     "ipni",
			Category: "Boost Only",
			Usage:    "Whether to announce the deal to IPNI",
			Value:    true,
		},
		&cli.BoolFlag{
			Name:     "keep-unsealed",
			Category: "Deal Proposal",
			Usage:    "Whether to keep unsealed copy",
			Value:    true,
		},
		&cli.StringFlag{
			Name:        "schedule-cron",
			Category:    "Scheduling",
			Aliases:     []string{"cron"},
			Usage:       "Cron schedule to send out batch deals",
			DefaultText: "disabled",
			Value:       "",
		},
		&cli.StringFlag{
			Name:     "start-delay",
			Category: "Deal Proposal",
			Aliases:  []string{"s"},
			Usage:    "Deal start delay in epoch or in duration format, i.e. 1000, 72h",
			Value:    "72h",
		},
		&cli.StringFlag{
			Name:     "duration",
			Category: "Deal Proposal",
			Aliases:  []string{"d"},
			Usage:    "Duration in epoch or in duration format, i.e. 1500000, 2400h",
			Value:    "12840h",
		},
		&cli.IntFlag{
			Name:        "schedule-deal-number",
			Category:    "Scheduling",
			Aliases:     []string{"number"},
			Usage:       "Max deal number per triggered schedule, i.e. 30",
			DefaultText: "Unlimited",
		},
		&cli.IntFlag{
			Name:        "total-deal-number",
			Category:    "Scheduling",
			Aliases:     []string{"total-number"},
			Usage:       "Max total deal number for this request, i.e. 1000",
			DefaultText: "Unlimited",
		},
		&cli.StringFlag{
			Name:        "schedule-deal-size",
			Category:    "Scheduling",
			Aliases:     []string{"size"},
			Usage:       "Max deal sizes per triggered schedule, i.e. 500GB",
			DefaultText: "Unlimited",
			Value:       "0",
		},
		&cli.StringFlag{
			Name:        "total-deal-size",
			Category:    "Restrictions",
			Aliases:     []string{"total-size"},
			Usage:       "Max total deal sizes for this request, i.e. 100TB",
			DefaultText: "Unlimited",
			Value:       "0",
		},
		&cli.StringFlag{
			Name:     "notes",
			Category: "Tracking",
			Aliases:  []string{"n"},
			Usage:    "Any notes or tag to store along with the request, for tracking purpose",
			Value:    "",
		},
		&cli.StringFlag{
			Name:        "max-pending-deal-size",
			Category:    "Restrictions",
			Aliases:     []string{"pending-size"},
			Usage:       "Max pending deal sizes overall for this request",
			DefaultText: "Unlimited",
			Value:       "0",
		},
		&cli.IntFlag{
			Name:        "max-pending-deal-number",
			Category:    "Restrictions",
			Aliases:     []string{"pending-number"},
			Usage:       "Max pending deal number overall for this request",
			DefaultText: "Unlimited",
		},
		&cli.StringSliceFlag{
			Name:        "allowed-piece-cid",
			Category:    "Restrictions",
			Aliases:     []string{"piece-cid"},
			Usage:       "List of allowed piece CIDs in this schedule",
			DefaultText: "Any",
		},
		&cli.StringSliceFlag{
			Name:     "allowed-piece-cid-file",
			Category: "Restrictions",
			Aliases:  []string{"piece-cid-file"},
			Usage:    "List of files that contains a list of piece CIDs to allow",
		},
	},
	Action: func(c *cli.Context) error {
		db, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		cids := map[string]struct{}{}
		for _, f := range c.StringSlice("allowed-piece-cid-file") {
			cidsFromFile, err := readCIDsFromFile(f)
			if err != nil {
				return err
			}
			for _, cid := range cidsFromFile {
				cids[cid] = struct{}{}
			}
		}
		for _, cid := range c.StringSlice("allowed-piece-cid") {
			cids[cid] = struct{}{}
		}
		var allowedPieceCIDs []string
		for cid := range cids {
			allowedPieceCIDs = append(allowedPieceCIDs, cid)
		}
		request := schedule.CreateRequest{
			DatasetName:          c.Args().Get(0),
			Provider:             c.Args().Get(1),
			HTTPHeaders:          c.StringSlice("http-header"),
			URLTemplate:          c.String("url-template"),
			PricePerGBEpoch:      c.Float64("price-per-gb-epoch"),
			PricePerGB:           c.Float64("price-per-gb"),
			PricePerDeal:         c.Float64("price-per-deal"),
			Verified:             c.Bool("verified"),
			IPNI:                 c.Bool("ipni"),
			KeepUnsealed:         c.Bool("keep-unsealed"),
			ScheduleCron:         c.String("schedule-cron"),
			StartDelay:           c.String("start-delay"),
			Duration:             c.String("duration"),
			ScheduleDealNumber:   c.Int("schedule-deal-number"),
			TotalDealNumber:      c.Int("total-deal-number"),
			ScheduleDealSize:     c.String("schedule-deal-size"),
			TotalDealSize:        c.String("total-deal-size"),
			Notes:                c.String("notes"),
			MaxPendingDealSize:   c.String("max-pending-deal-size"),
			MaxPendingDealNumber: c.Int("max-pending-deal-number"),
			AllowedPieceCIDs:     allowedPieceCIDs,
		}
		lotusClient := util.NewLotusClient(c.String("lotus-api"), c.String("lotus-token"))
		schedule, err := schedule.CreateHandler(db, c.Context, lotusClient, request)
		if err != nil {
			return err
		}

		cliutil.PrintToConsole(schedule, c.Bool("json"), nil)
		return nil
	},
}
View Source
var ListCmd = &cli.Command{
	Name:  "list",
	Usage: "List all deal making schedules",
	Action: func(c *cli.Context) error {
		db, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		schedules, err := schedule.ListHandler(db)
		if err != nil {
			return err
		}

		cliutil.PrintToConsole(schedules, c.Bool("json"), nil)
		return nil
	},
}
View Source
var PauseCmd = &cli.Command{
	Name:      "pause",
	Usage:     "Pause a specific schedule",
	ArgsUsage: "SCHEDULE_ID",
	Action: func(c *cli.Context) error {
		db, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		schedule, err := schedule.PauseHandler(db, c.Args().Get(0))
		if err != nil {
			return err
		}
		cliutil.PrintToConsole(schedule, c.Bool("json"), nil)
		return nil
	},
}
View Source
var ResumeCmd = &cli.Command{
	Name:      "resume",
	Usage:     "Resume a specific schedule",
	ArgsUsage: "SCHEDULE_ID",
	Action: func(c *cli.Context) error {
		db, err := database.OpenFromCLI(c)
		if err != nil {
			return err
		}
		schedule, err := schedule.ResumeHandler(db, c.Args().Get(0))
		if err != nil {
			return err
		}
		cliutil.PrintToConsole(schedule, c.Bool("json"), nil)
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL