ããããã°ãå¤ãè¯ãæ代ã¯èªåã®ããã¯ãã¼ã¯ã¯èªåã§Twitterã«æ稿ããã¦ããã®ã ã£ãã ä»ã¯Blueskyãã¡ã¤ã³ã«ãªã£ã¦ããã®ã§ãåãä»çµã¿ã欲ãããã¨æã£ããã®ã§ãä½ã£ãã
è¦ä»¶
èªåã®ããã¯ãã¼ã¯ã¯RSSã§åå¾ã§ãããå®æçã«ãã§ãã¯ãã¦æ°ããã®ãããã°ãã¨ãã£ããã¸ãã¯ã§æ¤åºã§ããã ãªã®ã§ãåºæ¬çã«ã¯ããã°ã©ã ãå®æå®è¡ã§ããå ´æãããã°GitHub Actionsã¨ãã§ãè¯ãã ãã ã対象ã®ãã¯ãå 容ãpostããåã«ããããæ¢ã«postãã¦ãããå¦ããç¥ãå¿ è¦ãããã
å°ç¨ã®botã¢ã«ã¦ã³ãã¨ãã§ããã°ããã®ã¢ã«ã¦ã³ãã®post feedãåå¾ãã¦æè¿ã®ãã®ããã§ãã¯ããã°ç¢ºèªå¯è½ã ããèªåã®ã¢ã«ã¦ã³ãã«æµãå ´åã¯ãã®æ¹æ³ã ã¨æåã§å¤§éã«postããããã¦ããã¿ã¤ãã³ã°ã ã¨åããã¦ãã¾ãã ãã£ã¦ãä½ããã®æ¹æ³ã§postæ¸ã¿ã®ãã®ãä¿æãã¦ããå¿ è¦ãããã
å è¡äºä¾
ã§ãè¯ããªã¨æã£ãã®ãããã
Cloudflare Workersã§ã Cron Triggers ã§å®æå®è¡ã§ãã¦ãã¾ã Workers KV ã®ãããªãã®ã§ãã¼ã¿ãä¿åãã¦ãããã¨ãã§ããã ä¸è¿°è¦ä»¶ãæºãããã©ãããã©ã¼ã ã¨ãã¦ã¯ã¡ããã©è¯ãããã
Rustç
åè¿°ã®ããã®ã¾ã¾ä½¿ããã¦ããã ãã¦ãè¯ãã£ãã®ã ãã©ãæè§ ATProtocolã®Rustã©ã¤ãã©ãªãä½ã£ã¦ãã ã®ã ããRustã§åããããªæ©è½ã®ãã®ãä½ã£ã¦ã¿ããã¨ã«ããã
WASM対å¿
ã¾ãæä½ ATrium ã使ã£ã¦ã¿ããã¨ããã¨ãããæ©éãã«ãã«å¤±æããã
ãã¾ãèãã¦ããªãã£ããã wasm32-unknown-unknown
ã®targetã§ãã«ããããã¨ããã¨å¤±æããç®æãå¤ã
ãã£ãã
ã®ã§ãã¾ãã¯ããããã
主ã«åé¡ã¯ async-trait
ã使ã£ã¦ããã¨ããã§ãããã Send
ãè¦æ±ãããã wasm32
targetã®å ´åã«åé¡ã«ãªãããã ã£ãã
ãã㯠(?Send)
ã追å ãããã¨ã§åé¿ã§ããã¨ã®ãã¨ã wasm32
targetã®ã¨ãã ãããã追å ããå½¢ã«å¤æ´ãããä»ã®targetã®å ´åã¯ä½ãå½±é¿ãåããªãã
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(not(target_arch = "wasm32"), async_trait)]
ãã¨ã¯ atrium-xrpc-client
ã¨ããå°ç¨ã®éåæHTTP Clientãå¹¾ã¤ãæä¾ãã¦ããããããã㯠reqwest
backendã®ãã®ä»¥å¤ã¯ãã¹ã¦wasm32ã«ã¯å¯¾å¿ãã¦ããªãã£ãã®ã§ã諸ã
å¤æ´ã㦠wasm32
ã®å ´å㯠reqwest
ã®Clientã ããå©ç¨å¯è½ã«ãªãããã«ããã
Cloudflare Workersã§ã®å®è£
以åã®è¨äº ã§ãæ¸ããéããCloudflare Workersã¯Rustç°å¢ã§ãä½æãããã¨ãã§ãããä»åã®ãã®ãJavaScript/TypeScriptã1è¡ãæ¸ããã«ä½æã§ããã
Cron Triggersç¨ã« #[event(scheduled)]
ãã¤ããé¢æ°ãå®è£
ããã ãã
1MBå¶éã¨ã®æ¦ã
ãã£ããè²ããªã©ã¤ãã©ãªãä¾åã«å ¥ãã¦ããã¨ããã«ãå¾ã®ãµã¤ãºãç¡ææ ä¸éã®1MBãè¶ ãã¦ãã¾ãã
RSSã®è§£æã«æå㯠feed-rs
ã使ã£ã¦ããããã¡ãã£ã¨å¤§ããããã ã£ãã®ã§ãã£ã¨ã·ã³ãã«ã«RSS 1.0ã®ãã®ã ãæ±ãã rss
ã«å¤æ´ãããããã
Fetch API
ãã¼ã«ã«å®è¡ããæã®æè¦ã§ reqwest
ããã³ã³ãã³ãåå¾ã atrium-xrpc-client
ã®ããã¯ã¨ã³ãã¨ãã¦ä½¿ã£ã¦ããããå®ã¯å¿
è¦ãªãã£ãâ¦
worker-rs
ã«ã¯ worker::Fetch
ããããããã使ããã¨ã§HTTPãªã¯ã¨ã¹ããå¦çã§ããã
ATriumã§ã¯ãéåæHTTP Clientã¨ãã¦ã¯ã©ããªãã®ã使ã£ã¦ãè¯ãããã«Traitã ãç¨æãã¦éçºè
ãèªç±ã«Clientãå®è£
ã»é¸æã§ããããã«è¨è¨ãã¦ããã
ã®ã§ãä»å㯠worker::Fetch
ã使ãããã«å°ãç¹ãé¨åãæ¸ãã ãã§XRPC Clientã¨ãã¦åé¡ãªãå©ç¨ã§ããããã«ãªã£ãã
ãã ãæ¬æ¥ãã®Fetch APIã使ã£ã¦ Transform images ãã§ããã¯ããªã®ã ããã©ããRustçã¯ã¾ã 対å¿ã§ãã¦ããªãã£ã½ãã
ç¡çç¢çããã°ã§ããã®ããªâ¦ ã¨ã¯ããOGPã®ç»åã¯ããã¨å¤æãããã«ãã®ã¾ã¾ uploadBlob
ãã¦ã失æãããã¨ã¯å°ãªããï¼ãªã®ã§ãã°ããæ§åè¦ã§ããããªã
KVã§ã®SessionStoreï¼
ã¡ãªã¿ã« atrium-api
ã§ã¯ã»ãã·ã§ã³æ
å ±ã管çãã AtpAgent
ã¨ããã®ãç¨æãã¦ãã¦ãããã§ã¯ SessionStore
ãèªåã§å®è£
ãããã¨ã§èªè¨¼æ
å ±ãä¿æãã¦ãããã¨ãã§ããããã«è¨è¨ãã¦ããã
é常㯠memoryã«ä¿æããã ãã® MemorySessionStore
ãå©ç¨ããããä»åã®ãããªã±ã¼ã¹ã§ KV
ã使ã£ã¦ããã«ä¿æãã¦ãããã¨ãã§ããªããï¼ ã¨è©¦ã¿ããããã¯ã Send
traitè¦æ±ã®å£ãããä¸æããããªãã£ã⦠ããã¯ã¡ãã£ã¨å¯¾å¿ããã®ãé£ããããªãã
ããããä»åã®ããã«é£ãã並åå¦çã¨ãç¡ããããªå ´åã¯ããããsessionä¿æãã¦ãããªãã¦ãé½åº¦ãã°ã¤ã³(createSession
)ãããã§åé¡ãªãããã§ã¯ããã