create_task project_id, location_id, queue_id, payload: nil, seconds: nil

in appengine/standard-cloud-tasks/create_task.rb [23:56]


def create_task project_id, location_id, queue_id, payload: nil, seconds: nil
  
  client = Google::Cloud::Tasks.cloud_tasks

  
  parent = client.queue_path project: project_id, location: location_id, queue: queue_id

  
  task = {
    app_engine_http_request: {
      http_method:  "POST",
      relative_uri: "/log_payload"
    }
  }

  
  if payload
    task[:app_engine_http_request][:body] = payload
  end

  
  if seconds
    timestamp = Google::Protobuf::Timestamp.new
    timestamp.seconds = Time.now.to_i + seconds.to_i
    task[:schedule_time] = timestamp
  end

  
  puts "Sending task #{task}"
  response = client.create_task parent: parent, task: task

  puts "Created task #{response.name}" if response.name
end