Class: Pindo::TaskSystem::UnityTask

Inherits:
PindoTask
  • Object
show all
Defined in:
lib/pindo/module/task/model/unity_task.rb

Overview

Unity 任务基类所有 Unity 相关任务的父类,提供通用的 Unity 操作和配置

Instance Attribute Summary collapse

Attributes inherited from PindoTask

#callbacks_setup, #context, #created_at, #data_dependencies, #dependencies, #error, #finished_at, #id, #max_retry_count, #metadata, #name, #priority, #result, #retry_count, #retry_delay, #retry_mode, #started_at, #status, #task_key, #task_manager, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PindoTask

#cancel, #cancelled?, #check_cancelled!, #data_param, #do_task, #execution_time, #finished?, #get_all_data_params, #get_all_data_params_by_key, #get_all_dependencies_results, #get_data_param, #get_data_param_by_key, #get_dependency_result, #get_dependency_task, #on, #primary_data_param, #reset_for_retry, #retryable?, #running?, #should_retry?, task_key

Constructor Details

#initialize(name, options = {}) ⇒ UnityTask

Returns a new instance of UnityTask.



12
13
14
15
16
17
# File 'lib/pindo/module/task/model/unity_task.rb', line 12

def initialize(name, options = {})
  @project_path = options[:project_path] ? File.expand_path(options[:project_path]) : nil
  @unity_root_path = options[:unity_root_path] || @project_path

  super(name, options)
end

Instance Attribute Details

#project_pathObject (readonly)

Returns the value of attribute project_path.



10
11
12
# File 'lib/pindo/module/task/model/unity_task.rb', line 10

def project_path
  @project_path
end

#unity_root_pathObject (readonly)

Returns the value of attribute unity_root_path.



10
11
12
# File 'lib/pindo/module/task/model/unity_task.rb', line 10

def unity_root_path
  @unity_root_path
end

Class Method Details

.default_retry_countObject



34
35
36
# File 'lib/pindo/module/task/model/unity_task.rb', line 34

def self.default_retry_count
  2  # Unity 任务默认重试 2 次
end

.default_retry_delayObject



38
39
40
# File 'lib/pindo/module/task/model/unity_task.rb', line 38

def self.default_retry_delay
  15  # Unity 任务默认延迟 15 秒重试
end

.default_retry_modeObject

Unity 任务默认重试配置



30
31
32
# File 'lib/pindo/module/task/model/unity_task.rb', line 30

def self.default_retry_mode
  RetryMode::DELAYED
end

.task_typeObject

Unity 任务类型



20
21
22
# File 'lib/pindo/module/task/model/unity_task.rb', line 20

def self.task_type
  :unity
end

.task_type_nameObject

Unity 任务类型显示名称



25
26
27
# File 'lib/pindo/module/task/model/unity_task.rb', line 25

def self.task_type_name
  "Unity操作"
end

Instance Method Details

#before_retryObject

重试前清理 Unity 进程



63
64
65
66
# File 'lib/pindo/module/task/model/unity_task.rb', line 63

def before_retry
  super
  cleanup_unity_processes
end

#unity_helperObject

获取 Unity Helper



58
59
60
# File 'lib/pindo/module/task/model/unity_task.rb', line 58

def unity_helper
  @unity_helper ||= Pindo::Unity::UnityHelper.share_instance
end

#validateObject

验证 Unity 项目路径



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/pindo/module/task/model/unity_task.rb', line 43

def validate
  super

  unless File.directory?(@project_path)
    raise Informative, "Unity 项目路径不存在: #{@project_path}"
  end

  unless File.directory?(@unity_root_path)
    raise Informative, "Unity 根目录不存在: #{@unity_root_path}"
  end

  true
end