kohaku

package module
v0.0.0-...-d530472 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

README

WebRTC Stats Collector Kohaku

GitHub tag (latest SemVer) 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 をお読みください。

WebRTC Stats Collector Kohaku について

Kohaku はクライアントと Sora の統計情報を Sora から HTTP/2 経由で受け取り、整理してタイムシリーズデータベースに格納するゲートウェイです。 現時点ではタイムシリーズデータベースは TimescaleDB のみに対応しています。

特徴

  • Sora から HTTP/2 経由でクライアントの統計情報を受け取り TimescaleDB (TSDB) に格納します
    • HTTPS 経由だけでなく HTTP 経由の h2c にも対応しています
  • WebRTC 統計 API に対応しています
    • ブラウザは最新 Chrome / Firefox / Safari / Edge へ対応
    • Sora SDK は iOS / Android / Unity / C++ / Python に対応
    • WebRTC Native Client Momo に対応
  • クライアントは Sora に統計情報を送るだけでよくなるため、どこかのサーバに対して接続などが不要になります
  • すべての統計情報を Sora の Channel ID と Connection ID と関連付けて保存するため問題の追跡がしやすくなります
  • Grafana ダッシュボードを用意

Grafana ダッシュボード

すぐに使い始められるように Grafana ダッシュボードを作り込んであります。 接続一覧からコネクション ID をクリックすると受信した音声や映像(inbound-rtp)の統計情報が確認できます。

Image from Gyazo

Image from Gyazo

使ってみる

Kohaku を使ってみたい人は USE.md をお読みください。

シーケンス

sequenceDiagram
  participant C as クライアント
  participant S as Sora
  participant K as Kohaku
  participant T as TimescaleDB
  participant G as Grafana
  note over K,T: DB 接続済み
  note over S,K: HTTP/2 確立済み
  note over C,S: WebRTC 確立済み
  S->>+C: type: stats-req
  C->>-S: type: stats<br>WebRTC 統計情報
  S-)K: WebRTC 統計情報 over HTTP/2
  K->>T: INSERT TO ...
  G->>T: SELECT ...
  T->>G: 結果
  S->>+C: type: stats-req
  C->>-S: type: stats<br>WebRTC 統計情報
  S-)K: WebRTC 統計情報 over HTTP/2
  K->>T: INSERT TO ...

ライセンス

Apache License 2.0

Copyright 2021-2023, Hiroshi Yoshida (Original Author)
Copyright 2021-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.

優先実装

優先実装とは Sora のライセンスを契約頂いているお客様限定で Kohaku の実装予定機能を有償にて前倒しで実装することです。

優先実装が可能な機能一覧

詳細は Discord やメールなどでお気軽にお問い合わせください

  • AWS Timestream 対応
  • SQLite 対応

記事

Documentation

Index

Constants

View Source
const (
	DefaultLogDir  = "."
	DefaultLogName = "kohaku.jsonl"

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

	DefaultExporterListenAddr = "0.0.0.0"
	DefaultExporterListenPort = 5891
)

Variables

View Source
var Version string

Functions

func InitLogger

func InitLogger(config *Config) error

InitLogger ロガーを初期化する

func NewPool

func NewPool(connStr string) (*pgxpool.Pool, error)

func ShowConfig

func ShowConfig(config *Config)

Types

type Config

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

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

	// MB
	LogRotateMaxSize    int `ini:"log_rotate_max_size"`
	LogRotateMaxBackups int `ini:"log_rotate_max_backups"`
	// Days
	LogRotateMaxAge int `ini:"log_rotate_max_age"`

	HTTPS      bool   `ini:"https"`
	ListenAddr string `ini:"listen_addr"`
	ListenPort int    `ini:"listen_port"`

	// exporter で https を使うかどうか
	// tailscale などを使う場合は不要
	ExporterHTTPS      bool   `ini:"exporter_https"`
	ExporterListenAddr string `ini:"exporter_listen_addr"`
	ExporterListenPort int    `ini:"exporter_listen_port"`

	PostgresURI        string `ini:"postgres_uri"`
	PostgresCACertFile string `ini:"postgres_ca_cert_file"`

	TLSFullchainFile    string `ini:"tls_fullchain_file"`
	TLSPrivkeyFile      string `ini:"tls_privkey_file"`
	TLSVerifyCacertPath string `ini:"tls_verify_cacert_path"`

	HTTP2MaxConcurrentStreams uint32 `ini:"http2_max_concurrent_streams"`
	HTTP2MaxReadFrameSize     uint32 `ini:"http2_max_read_frame_size"`
	HTTP2IdleTimeout          uint32 `ini:"http2_idle_timeout"`
}

func NewConfig

func NewConfig(configFilePath string) (*Config, error)

type RTCStats

type RTCStats struct {
	Timestamp float64 `json:"timestamp"`
	ID        string  `json:"id"`
	Type      string  `json:"type"`
}

type Server

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

func NewServer

func NewServer(c *Config, pool *pgxpool.Pool) (*Server, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

func (*Server) StartExporter

func (s *Server) StartExporter(ctx context.Context) error

type Validator

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

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Directories

Path Synopsis
cmd
gen

Jump to

Keyboard shortcuts

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