View Source Glific.GCS.GcsWorker (Glific v5.1.6)

Process the media table for each organization. Chunk number of message medias in groups of 128 and create a Gcs Worker Job to deliver the message media url to the gcs servers

We centralize both the cron job and the worker job in one module

Link to this section Summary

Functions

Download a file to the specific path. Should move this to a more generic helper file in glific

Standard perform method to use Oban worker

This is called from the cron job on a regular schedule. we sweep the message media url table and queue them up for delivery to gcs

Public interface to upload a file provided by the org at local name to gcs as remote name

Link to this section Functions

Link to this function

download_file_to_temp(url, path, org_id)

View Source
@spec download_file_to_temp(String.t(), String.t(), non_neg_integer()) ::
  {:ok, String.t()} | {:error, any()}

Download a file to the specific path. Should move this to a more generic helper file in glific

@spec perform(Oban.Job.t()) :: :ok | {:error, String.t()} | {:discard, String.t()}

Standard perform method to use Oban worker

Link to this function

perform_periodic(organization_id)

View Source
@spec perform_periodic(non_neg_integer()) :: :ok

This is called from the cron job on a regular schedule. we sweep the message media url table and queue them up for delivery to gcs

Link to this function

queue_urls(organization_id, min_id, max_id)

View Source
@spec queue_urls(non_neg_integer(), non_neg_integer(), non_neg_integer()) :: :ok

Queue urls for gcs jobs.

Link to this function

upload_media(local, remote, organization_id)

View Source
@spec upload_media(String.t(), String.t(), non_neg_integer()) ::
  {:ok, map()} | {:error, String.t()}

Public interface to upload a file provided by the org at local name to gcs as remote name