github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/protocol/gregor1/remind.go (about)

     1  // Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: avdl/gregor1/remind.avdl
     3  
     4  package gregor1
     5  
     6  import (
     7  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     8  	context "golang.org/x/net/context"
     9  	"time"
    10  )
    11  
    12  type GetRemindersArg struct {
    13  	MaxReminders int `codec:"maxReminders" json:"maxReminders"`
    14  }
    15  
    16  type DeleteRemindersArg struct {
    17  	ReminderIDs []ReminderID `codec:"reminderIDs" json:"reminderIDs"`
    18  }
    19  
    20  type RemindInterface interface {
    21  	// getReminders gets the reminders waiting to be sent out as a batch. Get at most
    22  	// maxReminders back.
    23  	GetReminders(context.Context, int) (ReminderSet, error)
    24  	// deleteReminders deletes all of the reminders by ReminderID
    25  	DeleteReminders(context.Context, []ReminderID) error
    26  }
    27  
    28  func RemindProtocol(i RemindInterface) rpc.Protocol {
    29  	return rpc.Protocol{
    30  		Name: "gregor.1.remind",
    31  		Methods: map[string]rpc.ServeHandlerDescription{
    32  			"getReminders": {
    33  				MakeArg: func() interface{} {
    34  					var ret [1]GetRemindersArg
    35  					return &ret
    36  				},
    37  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    38  					typedArgs, ok := args.(*[1]GetRemindersArg)
    39  					if !ok {
    40  						err = rpc.NewTypeError((*[1]GetRemindersArg)(nil), args)
    41  						return
    42  					}
    43  					ret, err = i.GetReminders(ctx, typedArgs[0].MaxReminders)
    44  					return
    45  				},
    46  			},
    47  			"deleteReminders": {
    48  				MakeArg: func() interface{} {
    49  					var ret [1]DeleteRemindersArg
    50  					return &ret
    51  				},
    52  				Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
    53  					typedArgs, ok := args.(*[1]DeleteRemindersArg)
    54  					if !ok {
    55  						err = rpc.NewTypeError((*[1]DeleteRemindersArg)(nil), args)
    56  						return
    57  					}
    58  					err = i.DeleteReminders(ctx, typedArgs[0].ReminderIDs)
    59  					return
    60  				},
    61  			},
    62  		},
    63  	}
    64  }
    65  
    66  type RemindClient struct {
    67  	Cli rpc.GenericClient
    68  }
    69  
    70  // getReminders gets the reminders waiting to be sent out as a batch. Get at most
    71  // maxReminders back.
    72  func (c RemindClient) GetReminders(ctx context.Context, maxReminders int) (res ReminderSet, err error) {
    73  	__arg := GetRemindersArg{MaxReminders: maxReminders}
    74  	err = c.Cli.Call(ctx, "gregor.1.remind.getReminders", []interface{}{__arg}, &res, 0*time.Millisecond)
    75  	return
    76  }
    77  
    78  // deleteReminders deletes all of the reminders by ReminderID
    79  func (c RemindClient) DeleteReminders(ctx context.Context, reminderIDs []ReminderID) (err error) {
    80  	__arg := DeleteRemindersArg{ReminderIDs: reminderIDs}
    81  	err = c.Cli.Call(ctx, "gregor.1.remind.deleteReminders", []interface{}{__arg}, nil, 0*time.Millisecond)
    82  	return
    83  }