archive

package module
v0.0.0-...-933b562 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

README

Sora Archive Uploader

License

About Shiguredo's open source software

We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.

Please read https://github.com/shiguredo/oss/blob/master/README.en.md before use.

時雨堂のオープンソースソフトウェアについて

利用前に https://github.com/shiguredo/oss をお読みください。

Sora Archive Uploader について

Sora が出力する録画関連のファイルを S3 または S3 互換オブジェクトストレージにアップロードするツールです。 systemd タイマーユニットを利用しての定期実行を想定しています。

Sora Cloud で実際に利用している仕組みからツールとして切り出して公開しています。

目的

Sora は録画を行った場合、録画ファイルを WebM 、録画メタデータ JSON ファイルで出力します。 Sora Cloud では出力されたファイルをオブジェクトストレージにアップロードする仕組みが必要となり開発しました。

特徴

  • systemd の設定だけで利用できます
  • 並列でオブジェクトストレージにアップロードできます
  • アップロード完了時に指定された URL にウェブフックリクエストを通知します
  • ウェブフックにはベーシック認証や mTLS が利用可能です
  • アップロードに失敗した場合は設定ファイルで指定した隔離ディレクトリに移動します
  • アップロードの帯域制限を設定できます
対応オブジェクトストレージ
  • AWS S3
  • MinIO
  • GCP GCS
  • Vultr Object Storage
  • Linode Object Storage
  • DigitalOcean Spaces
  • Cloudflare R2

まずは使ってみる

config.ini に必要な情報を設定してください。

$ cp config_example.ini config.ini

make でビルドして実行します。

$ make
$ ./bin/sora-archive-uploader -C config.ini

Discord

最新の状況などは Discord で共有しています。質問や相談も Discord でのみ受け付けています。

https://discord.gg/shiguredo

有償での優先実装が可能な機能一覧

詳細は Discord またはメールにてお問い合わせください

  • オープンソースでの公開が前提
  • 可能であれば企業名の公開
    • 公開が難しい場合は 企業名非公開 と書かせていただきます
機能

ライセンス

Copyright 2022-2023, Takeshi Namao (Original Author)
Copyright 2022-2023, Shiguredo Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Documentation

Index

Constants

View Source
const (
	DefaultLogDir  = "."
	DefaultLogName = "sora-archive-uploader.jsonl"

	// megabytes
	DefaultLogRotateMaxSize    = 200
	DefaultLogRotateMaxBackups = 7
	// days
	DefaultLogRotateMaxAge = 30
)

Variables

View Source
var Version string

Functions

func Run

func Run(configFilePath *string)

Types

type ArchiveEndMetadata

type ArchiveEndMetadata struct {
	RecordingID  string `json:"recording_id"`
	ChannelID    string `json:"channel_id"`
	SessionID    string `json:"session_id"`
	ClientID     string `json:"client_id"`
	ConnectionID string `json:"connection_id"`
	FilePath     string `json:"file_path"`
	Filename     string `json:"filename"`
}

type ArchiveMetadata

type ArchiveMetadata struct {
	RecordingID      string `json:"recording_id"`
	ChannelID        string `json:"channel_id"`
	SessionID        string `json:"session_id"`
	ClientID         string `json:"client_id"`
	ConnectionID     string `json:"connection_id"`
	FilePath         string `json:"file_path"`
	Filename         string `json:"filename"`
	MetadataFilePath string `json:"metadata_file_path"`
	MetadataFilename string `json:"metadata_filename"`
}

type Config

type Config struct {
	Debug bool `ini:"debug"`

	LogDir    string `ini:"log_dir"`
	LogName   string `ini:"log_name"`
	LogStdout bool   `ini:"log_stdout"`

	LogRotateMaxSize    int  `ini:"log_rotate_max_size"`
	LogRotateMaxBackups int  `ini:"log_rotate_max_backups"`
	LogRotateMaxAge     int  `ini:"log_rotate_max_age"`
	LogRotateCompress   bool `ini:"log_rotate_compress"`

	ObjectStorageEndpoint        string `ini:"object_storage_endpoint"`
	ObjectStorageBucketName      string `ini:"object_storage_bucket_name"`
	ObjectStorageAccessKeyID     string `ini:"object_storage_access_key_id"`
	ObjectStorageSecretAccessKey string `ini:"object_storage_secret_access_key"`

	SoraArchiveDirFullPath  string `ini:"archive_dir_full_path"`
	SoraEvacuateDirFullPath string `ini:"evacuate_dir_full_path"`

	UploadWorkers int `ini:"upload_workers"`

	// 1 ファイルあたりのアップロードレート制限
	UploadFileRateLimitMbps int `ini:"upload_file_rate_limit_mbps"`

	UploadedFileCacheSize int `ini:"uploaded_file_cache_size"`

	WebhookEndpointURL            string `ini:"webhook_endpoint_url"`
	WebhookEndpointHealthCheckURL string `ini:"webhook_endpoint_health_check_url"`

	WebhookTypeHeaderName              string `ini:"webhook_type_header_name"`
	WebhookTypeArchiveUploaded         string `ini:"webhook_type_archive_uploaded"`
	WebhookTypeSplitArchiveUploaded    string `ini:"webhook_type_split_archive_uploaded"`
	WebhookTypeSplitArchiveEndUploaded string `ini:"webhook_type_split_archive_end_uploaded"`
	WebhookTypeReportUploaded          string `ini:"webhook_type_report_uploaded"`

	ExcludeWebhookRecordingMetadata bool `ini:"exclude_webhook_recording_metadata"`

	WebhookBasicAuthUsername string `ini:"webhook_basic_auth_username"`
	WebhookBasicAuthPassword string `ini:"webhook_basic_auth_password"`

	WebhookRequestTimeoutS int32 `ini:"webhook_request_timeout_s"`

	WebhookTLSVerifyCacertPath string `ini:"webhook_tls_verify_cacert_path"`
	WebhookTLSFullchainPath    string `ini:"webhook_tls_fullchain_path"`
	WebhookTLSPrivkeyPath      string `ini:"webhook_tls_privkey_path"`
}

func (Config) IncludeWebhookRecordingMetadata

func (c Config) IncludeWebhookRecordingMetadata() bool

type GateKeeper

type GateKeeper struct {
	// contains filtered or unexported fields
}

type Main

type Main struct {
	// contains filtered or unexported fields
}

type RecordingReport

type RecordingReport struct {
	RecordingID       string          `json:"recording_id"`
	ChannelID         string          `json:"channel_id"`
	SessionID         string          `json:"session_id"`
	FilePath          string          `json:"file_path"`
	Filename          string          `json:"filename"`
	Metadata          json.RawMessage `json:"metadata"`
	RecordingMetadata json.RawMessage `json:"recording_metadata"`
}

type RecordingUnit

type RecordingUnit struct {
	// contains filtered or unexported fields
}

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

func (Uploader) Stop

func (u Uploader) Stop()

type UploaderManager

type UploaderManager struct {
	ArchiveStream    chan UploaderResult
	ArchiveEndStream chan UploaderResult
	ReportStream     chan UploaderResult
	// contains filtered or unexported fields
}

type UploaderResult

type UploaderResult struct {
	Success  bool
	Filepath string
}

type WebhookArchiveEndUploaded

type WebhookArchiveEndUploaded struct {
	ID           string    `json:"id"`
	Type         string    `json:"type"`
	Timestamp    time.Time `json:"timestamp"`
	RecordingID  string    `json:"recording_id"`
	SessionID    string    `json:"session_id"`
	ClientID     string    `json:"client_id"`
	ChannelID    string    `json:"channel_id"`
	ConnectionID string    `json:"connection_id"`
	Filename     string    `json:"filename"`
	FileURL      string    `json:"file_url"`
}

type WebhookArchiveUploaded

type WebhookArchiveUploaded struct {
	ID               string    `json:"id"`
	Type             string    `json:"type"`
	Timestamp        time.Time `json:"timestamp"`
	RecordingID      string    `json:"recording_id"`
	SessionID        string    `json:"session_id"`
	ClientID         string    `json:"client_id"`
	ChannelID        string    `json:"channel_id"`
	ConnectionID     string    `json:"connection_id"`
	Filename         string    `json:"filename"`
	FileURL          string    `json:"file_url"`
	MetadataFilename string    `json:"metadata_filename"`
	MetadataFileURL  string    `json:"metadata_file_url"`
}

type WebhookReportUploaded

type WebhookReportUploaded struct {
	ID                string          `json:"id"`
	Type              string          `json:"type"`
	Timestamp         time.Time       `json:"timestamp"`
	RecordingID       string          `json:"recording_id"`
	ChannelID         string          `json:"channel_id"`
	Filename          string          `json:"filename"`
	FileURL           string          `json:"file_url"`
	RecordingMetadata json.RawMessage `json:"recording_metadata,omitempty"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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