task

package
v0.0.0-...-7aae7b9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "task"
)

Variables

View Source
var (
	Stage_name = map[int32]string{
		0: "PENDDING",
		1: "RUNNING",
		2: "SUCCESS",
		3: "FAILED",
		4: "WARNING",
	}
	Stage_value = map[string]int32{
		"PENDDING": 0,
		"RUNNING":  1,
		"SUCCESS":  2,
		"FAILED":   3,
		"WARNING":  4,
	}
)

Enum value maps for Stage.

View Source
var (
	Type_name = map[int32]string{
		0: "RESOURCE_SYNC",
		1: "RESOURCE_RELEASE",
	}
	Type_value = map[string]int32{
		"RESOURCE_SYNC":    0,
		"RESOURCE_RELEASE": 1,
	}
)

Enum value maps for Type.

View Source
var File_apps_task_pb_rpc_proto protoreflect.FileDescriptor
View Source
var File_apps_task_pb_task_proto protoreflect.FileDescriptor
View Source
var Service_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "infraboard.cmdb.task.Service",
	HandlerType: (*ServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreatTask",
			Handler:    _Service_CreatTask_Handler,
		},
		{
			MethodName: "QueryTask",
			Handler:    _Service_QueryTask_Handler,
		},
		{
			MethodName: "DescribeTask",
			Handler:    _Service_DescribeTask_Handler,
		},
		{
			MethodName: "QueryTaskRecord",
			Handler:    _Service_QueryTaskRecord_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "apps/task/pb/rpc.proto",
}

Service_ServiceDesc is the grpc.ServiceDesc for Service service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterServiceServer

func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer)

Types

type CreateTaskRequst

type CreateTaskRequst struct {

	// 任务类型
	// @gotags: json:"type"
	Type Type `protobuf:"varint,1,opt,name=type,proto3,enum=infraboard.cmdb.task.Type" json:"type"`
	// 测试运行
	// @gotags: json:"dry_run"
	DryRun bool `protobuf:"varint,2,opt,name=dry_run,json=dryRun,proto3" json:"dry_run"`
	// 任务使用的云商凭证Id
	// @gotags: json:"credential_id" validate:"required,lte=100"
	CredentialId string `protobuf:"bytes,3,opt,name=credential_id,json=credentialId,proto3" json:"credential_id" validate:"required,lte=100"`
	// 任务操作的资源类型
	// @gotags: json:"resource_type"
	ResourceType resource.TYPE `protobuf:"varint,4,opt,name=resource_type,json=resourceType,proto3,enum=infraboard.cmdb.resource.TYPE" json:"resource_type"`
	// 通知资源的Region
	// @gotags: json:"region"
	Region string `protobuf:"bytes,5,opt,name=region,proto3" json:"region"`
	// 额外的一些参数
	// @gotags: json:"params"
	Params map[string]string `` /* 143-byte string literal not displayed */
	// 任务执行的超时时间
	// @gotags: json:"timeout"
	Timeout int64 `protobuf:"varint,7,opt,name=timeout,proto3" json:"timeout"`
	// 任务所属域
	// @gotags: json:"domain"
	Domain string `protobuf:"bytes,8,opt,name=domain,proto3" json:"domain"`
	// 任务所属空间
	// @gotags: json:"namespace"
	Namespace string `protobuf:"bytes,9,opt,name=namespace,proto3" json:"namespace"`
	// contains filtered or unexported fields
}

func NewCreateTaskRequst

func NewCreateTaskRequst() *CreateTaskRequst

func (*CreateTaskRequst) Descriptor deprecated

func (*CreateTaskRequst) Descriptor() ([]byte, []int)

Deprecated: Use CreateTaskRequst.ProtoReflect.Descriptor instead.

func (*CreateTaskRequst) GetCredentialId

func (x *CreateTaskRequst) GetCredentialId() string

func (*CreateTaskRequst) GetDomain

func (x *CreateTaskRequst) GetDomain() string

func (*CreateTaskRequst) GetDryRun

func (x *CreateTaskRequst) GetDryRun() bool

func (*CreateTaskRequst) GetNamespace

func (x *CreateTaskRequst) GetNamespace() string

func (*CreateTaskRequst) GetParams

func (x *CreateTaskRequst) GetParams() map[string]string

func (*CreateTaskRequst) GetRegion

func (x *CreateTaskRequst) GetRegion() string

func (*CreateTaskRequst) GetResourceType

func (x *CreateTaskRequst) GetResourceType() resource.TYPE

func (*CreateTaskRequst) GetTimeout

func (x *CreateTaskRequst) GetTimeout() int64

func (*CreateTaskRequst) GetType

func (x *CreateTaskRequst) GetType() Type

func (*CreateTaskRequst) ProtoMessage

func (*CreateTaskRequst) ProtoMessage()

func (*CreateTaskRequst) ProtoReflect

func (x *CreateTaskRequst) ProtoReflect() protoreflect.Message

func (*CreateTaskRequst) Reset

func (x *CreateTaskRequst) Reset()

func (*CreateTaskRequst) String

func (x *CreateTaskRequst) String() string

func (*CreateTaskRequst) Validate

func (req *CreateTaskRequst) Validate() error

type DescribeTaskRequest

type DescribeTaskRequest struct {

	// Task id
	// @gotags: json:"id" validate:"required"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" validate:"required"`
	// contains filtered or unexported fields
}

func NewDescribeTaskRequestWithId

func NewDescribeTaskRequestWithId(id string) *DescribeTaskRequest

func (*DescribeTaskRequest) Descriptor deprecated

func (*DescribeTaskRequest) Descriptor() ([]byte, []int)

Deprecated: Use DescribeTaskRequest.ProtoReflect.Descriptor instead.

func (*DescribeTaskRequest) GetId

func (x *DescribeTaskRequest) GetId() string

func (*DescribeTaskRequest) ProtoMessage

func (*DescribeTaskRequest) ProtoMessage()

func (*DescribeTaskRequest) ProtoReflect

func (x *DescribeTaskRequest) ProtoReflect() protoreflect.Message

func (*DescribeTaskRequest) Reset

func (x *DescribeTaskRequest) Reset()

func (*DescribeTaskRequest) String

func (x *DescribeTaskRequest) String() string

type QueryTaskRecordRequest

type QueryTaskRecordRequest struct {

	// Task id
	// @gotags: json:"task_id" validate:"required"
	TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id" validate:"required"`
	// contains filtered or unexported fields
}

func NewQueryTaskRecordRequest

func NewQueryTaskRecordRequest(id string) *QueryTaskRecordRequest

func (*QueryTaskRecordRequest) Descriptor deprecated

func (*QueryTaskRecordRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryTaskRecordRequest.ProtoReflect.Descriptor instead.

func (*QueryTaskRecordRequest) GetTaskId

func (x *QueryTaskRecordRequest) GetTaskId() string

func (*QueryTaskRecordRequest) ProtoMessage

func (*QueryTaskRecordRequest) ProtoMessage()

func (*QueryTaskRecordRequest) ProtoReflect

func (x *QueryTaskRecordRequest) ProtoReflect() protoreflect.Message

func (*QueryTaskRecordRequest) Reset

func (x *QueryTaskRecordRequest) Reset()

func (*QueryTaskRecordRequest) String

func (x *QueryTaskRecordRequest) String() string

type QueryTaskRequest

type QueryTaskRequest struct {

	// 分页参数
	// @gotags: json:"page"
	Page *request.PageRequest `protobuf:"bytes,1,opt,name=page,proto3" json:"page"`
	// @gotags: json:"resource_type"
	ResourceType resource.TYPE `protobuf:"varint,3,opt,name=resource_type,json=resourceType,proto3,enum=infraboard.cmdb.resource.TYPE" json:"resource_type"`
	// @gotags: json:"keywords"
	Keywords string `protobuf:"bytes,4,opt,name=keywords,proto3" json:"keywords"`
	// contains filtered or unexported fields
}

func NewQueryTaskRequestFromHTTP

func NewQueryTaskRequestFromHTTP(r *http.Request) *QueryTaskRequest

func (*QueryTaskRequest) Descriptor deprecated

func (*QueryTaskRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryTaskRequest.ProtoReflect.Descriptor instead.

func (*QueryTaskRequest) GetKeywords

func (x *QueryTaskRequest) GetKeywords() string

func (*QueryTaskRequest) GetPage

func (x *QueryTaskRequest) GetPage() *request.PageRequest

func (*QueryTaskRequest) GetResourceType

func (x *QueryTaskRequest) GetResourceType() resource.TYPE

func (*QueryTaskRequest) OffSet

func (req *QueryTaskRequest) OffSet() int64

func (*QueryTaskRequest) ProtoMessage

func (*QueryTaskRequest) ProtoMessage()

func (*QueryTaskRequest) ProtoReflect

func (x *QueryTaskRequest) ProtoReflect() protoreflect.Message

func (*QueryTaskRequest) Reset

func (x *QueryTaskRequest) Reset()

func (*QueryTaskRequest) String

func (x *QueryTaskRequest) String() string

type Record

type Record struct {

	// 任务的Id
	// @gotags: json:"task_id"
	TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id"`
	// 记录创建时间
	// @gotags: json:"create_at"
	CreateAt int64 `protobuf:"varint,2,opt,name=create_at,json=createAt,proto3" json:"create_at"`
	// 资源实例Id
	// @gotags: json:"instance_id"
	InstanceId string `protobuf:"bytes,3,opt,name=instance_id,json=instanceId,proto3" json:"instance_id"`
	// 资源名称
	// @gotags: json:"name"
	Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name"`
	// 是否同步成功
	// @gotags: json:"is_success"
	IsSuccess bool `protobuf:"varint,5,opt,name=is_success,json=isSuccess,proto3" json:"is_success"`
	// 同步失败原因
	// @gotags: json:"message"
	Message string `protobuf:"bytes,6,opt,name=message,proto3" json:"message"`
	// contains filtered or unexported fields
}

用于描述资源同步的详情信息

func NewDefaultTaskRecord

func NewDefaultTaskRecord() *Record

func NewSyncFailedRecord

func NewSyncFailedRecord(taskId, instanceId, instanceName, message string) *Record

func NewSyncSucceedRecord

func NewSyncSucceedRecord(taskId, instanceId, instanceName string) *Record

func (*Record) Descriptor deprecated

func (*Record) Descriptor() ([]byte, []int)

Deprecated: Use Record.ProtoReflect.Descriptor instead.

func (*Record) GetCreateAt

func (x *Record) GetCreateAt() int64

func (*Record) GetInstanceId

func (x *Record) GetInstanceId() string

func (*Record) GetIsSuccess

func (x *Record) GetIsSuccess() bool

func (*Record) GetMessage

func (x *Record) GetMessage() string

func (*Record) GetName

func (x *Record) GetName() string

func (*Record) GetTaskId

func (x *Record) GetTaskId() string

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) ProtoReflect

func (x *Record) ProtoReflect() protoreflect.Message

func (*Record) Reset

func (x *Record) Reset()

func (*Record) String

func (x *Record) String() string

type RecordSet

type RecordSet struct {

	// @gotags: json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"`
	// @gotags: json:"items"
	Items []*Record `protobuf:"bytes,2,rep,name=items,proto3" json:"items"`
	// contains filtered or unexported fields
}

func NewRecordSet

func NewRecordSet() *RecordSet

func (*RecordSet) Add

func (s *RecordSet) Add(item *Record)

func (*RecordSet) Descriptor deprecated

func (*RecordSet) Descriptor() ([]byte, []int)

Deprecated: Use RecordSet.ProtoReflect.Descriptor instead.

func (*RecordSet) GetItems

func (x *RecordSet) GetItems() []*Record

func (*RecordSet) GetTotal

func (x *RecordSet) GetTotal() int64

func (*RecordSet) ProtoMessage

func (*RecordSet) ProtoMessage()

func (*RecordSet) ProtoReflect

func (x *RecordSet) ProtoReflect() protoreflect.Message

func (*RecordSet) Reset

func (x *RecordSet) Reset()

func (*RecordSet) String

func (x *RecordSet) String() string

type ServiceClient

type ServiceClient interface {
	CreatTask(ctx context.Context, in *CreateTaskRequst, opts ...grpc.CallOption) (*Task, error)
	QueryTask(ctx context.Context, in *QueryTaskRequest, opts ...grpc.CallOption) (*TaskSet, error)
	DescribeTask(ctx context.Context, in *DescribeTaskRequest, opts ...grpc.CallOption) (*Task, error)
	QueryTaskRecord(ctx context.Context, in *QueryTaskRecordRequest, opts ...grpc.CallOption) (*RecordSet, error)
}

ServiceClient is the client API for Service service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewServiceClient

func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient

type ServiceServer

type ServiceServer interface {
	CreatTask(context.Context, *CreateTaskRequst) (*Task, error)
	QueryTask(context.Context, *QueryTaskRequest) (*TaskSet, error)
	DescribeTask(context.Context, *DescribeTaskRequest) (*Task, error)
	QueryTaskRecord(context.Context, *QueryTaskRecordRequest) (*RecordSet, error)
	// contains filtered or unexported methods
}

ServiceServer is the server API for Service service. All implementations must embed UnimplementedServiceServer for forward compatibility

type Stage

type Stage int32
const (
	Stage_PENDDING Stage = 0
	Stage_RUNNING  Stage = 1
	Stage_SUCCESS  Stage = 2
	Stage_FAILED   Stage = 3
	Stage_WARNING  Stage = 4
)

func ParseStageFromString

func ParseStageFromString(str string) (Stage, error)

ParseStageFromString Parse Stage from string

func (Stage) Descriptor

func (Stage) Descriptor() protoreflect.EnumDescriptor

func (Stage) Enum

func (x Stage) Enum() *Stage

func (Stage) EnumDescriptor deprecated

func (Stage) EnumDescriptor() ([]byte, []int)

Deprecated: Use Stage.Descriptor instead.

func (Stage) Equal

func (t Stage) Equal(target Stage) bool

Equal type compare

func (Stage) IsIn

func (t Stage) IsIn(targets ...Stage) bool

IsIn todo

func (Stage) MarshalJSON

func (t Stage) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (Stage) Number

func (x Stage) Number() protoreflect.EnumNumber

func (Stage) String

func (x Stage) String() string

func (Stage) Type

func (Stage) Type() protoreflect.EnumType

func (*Stage) UnmarshalJSON

func (t *Stage) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type Status

type Status struct {

	// 任务状态
	// @gotags: json:"stage"
	Stage Stage `protobuf:"varint,1,opt,name=stage,proto3,enum=infraboard.cmdb.task.Stage" json:"stage"`
	// 失败时的异常信息
	// @gotags: json:"message"
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message"`
	// 开始同步的时间
	// @gotags: json:"start_at"
	StartAt int64 `protobuf:"varint,3,opt,name=start_at,json=startAt,proto3" json:"start_at"`
	// 同步结束时间
	// @gotags: json:"end_at"
	EndAt int64 `protobuf:"varint,4,opt,name=end_at,json=endAt,proto3" json:"end_at"`
	// 成功的条数
	// @gotags: json:"total_succeed"
	TotalSucceed int64 `protobuf:"varint,5,opt,name=total_succeed,json=totalSucceed,proto3" json:"total_succeed"`
	// 失败的条数
	// @gotags: json:"total_failed"
	TotalFailed int64 `protobuf:"varint,6,opt,name=total_failed,json=totalFailed,proto3" json:"total_failed"`
	// contains filtered or unexported fields
}

func (*Status) Descriptor deprecated

func (*Status) Descriptor() ([]byte, []int)

Deprecated: Use Status.ProtoReflect.Descriptor instead.

func (*Status) GetEndAt

func (x *Status) GetEndAt() int64

func (*Status) GetMessage

func (x *Status) GetMessage() string

func (*Status) GetStage

func (x *Status) GetStage() Stage

func (*Status) GetStartAt

func (x *Status) GetStartAt() int64

func (*Status) GetTotalFailed

func (x *Status) GetTotalFailed() int64

func (*Status) GetTotalSucceed

func (x *Status) GetTotalSucceed() int64

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) ProtoReflect

func (x *Status) ProtoReflect() protoreflect.Message

func (*Status) Reset

func (x *Status) Reset()

func (*Status) String

func (x *Status) String() string

type Task

type Task struct {

	// 任务id
	// @gotags: json:"id"
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
	// credential
	// @gotags: json:"credential_description"
	CredentialDescription string `protobuf:"bytes,2,opt,name=credential_description,json=credentialDescription,proto3" json:"credential_description"`
	// 任务描述
	// @gotags: json:"data"
	Data *CreateTaskRequst `protobuf:"bytes,3,opt,name=data,proto3" json:"data"`
	// 任务状态
	// @gotags: json:"status"
	Status *Status `protobuf:"bytes,4,opt,name=status,proto3" json:"status"`
	// contains filtered or unexported fields
}

Task 同个区域的同一种资源一次只能有1个task run

func NewDefaultTask

func NewDefaultTask() *Task

func NewTaskFromReq

func NewTaskFromReq(req *CreateTaskRequst) (*Task, error)

func (*Task) AddDetail

func (s *Task) AddDetail(d *Record)

func (*Task) Completed

func (s *Task) Completed()

func (*Task) Descriptor deprecated

func (*Task) Descriptor() ([]byte, []int)

Deprecated: Use Task.ProtoReflect.Descriptor instead.

func (*Task) Failed

func (s *Task) Failed(message string)

func (*Task) GetCredentialDescription

func (x *Task) GetCredentialDescription() string

func (*Task) GetData

func (x *Task) GetData() *CreateTaskRequst

func (*Task) GetId

func (x *Task) GetId() string

func (*Task) GetStatus

func (x *Task) GetStatus() *Status

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) ProtoReflect

func (x *Task) ProtoReflect() protoreflect.Message

func (*Task) Reset

func (x *Task) Reset()

func (*Task) Run

func (s *Task) Run()

func (*Task) String

func (x *Task) String() string

func (*Task) UpdateSecretDesc

func (s *Task) UpdateSecretDesc(desc string)

type TaskSet

type TaskSet struct {

	// @gotags: json:"total"
	Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total"`
	// @gotags: json:"items"
	Items []*Task `protobuf:"bytes,2,rep,name=items,proto3" json:"items"`
	// contains filtered or unexported fields
}

func NewTaskSet

func NewTaskSet() *TaskSet

func (*TaskSet) Add

func (r *TaskSet) Add(item *Task)

func (*TaskSet) Descriptor deprecated

func (*TaskSet) Descriptor() ([]byte, []int)

Deprecated: Use TaskSet.ProtoReflect.Descriptor instead.

func (*TaskSet) GetItems

func (x *TaskSet) GetItems() []*Task

func (*TaskSet) GetTotal

func (x *TaskSet) GetTotal() int64

func (*TaskSet) ProtoMessage

func (*TaskSet) ProtoMessage()

func (*TaskSet) ProtoReflect

func (x *TaskSet) ProtoReflect() protoreflect.Message

func (*TaskSet) Reset

func (x *TaskSet) Reset()

func (*TaskSet) String

func (x *TaskSet) String() string

type Type

type Type int32

任务类型

const (
	// 资源同步任务
	Type_RESOURCE_SYNC Type = 0
	// 资源释放任务
	Type_RESOURCE_RELEASE Type = 1
)

func ParseTypeFromString

func ParseTypeFromString(str string) (Type, error)

ParseTypeFromString Parse Type from string

func (Type) Descriptor

func (Type) Descriptor() protoreflect.EnumDescriptor

func (Type) Enum

func (x Type) Enum() *Type

func (Type) EnumDescriptor deprecated

func (Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Type.Descriptor instead.

func (Type) Equal

func (t Type) Equal(target Type) bool

Equal type compare

func (Type) IsIn

func (t Type) IsIn(targets ...Type) bool

IsIn todo

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

MarshalJSON todo

func (Type) Number

func (x Type) Number() protoreflect.EnumNumber

func (Type) String

func (x Type) String() string

func (Type) Type

func (Type) Type() protoreflect.EnumType

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON todo

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedServiceServer) CreatTask

func (UnimplementedServiceServer) DescribeTask

func (UnimplementedServiceServer) QueryTask

func (UnimplementedServiceServer) QueryTaskRecord

type UnsafeServiceServer

type UnsafeServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ServiceServer will result in compilation errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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