Philocode
time sleep 2 real 0m2.004s user 0m0.001s sys 0m0.003s
دستور time فقط زمان رو میگه، ولی اگه خواستیم مصرف منابع رو بسنجیم:
/usr/bin/time -v docker ps
👍1🔥1
توصیه میکنم که قبل و بعد این بخش رو هم خوب بخونید:
https://learn.microsoft.com/en-us/azure/architecture/microservices/model/domain-analysis
https://learn.microsoft.com/en-us/azure/architecture/microservices/model/domain-analysis
Docs
Domain analysis for microservices - Azure Architecture Center
This article shows a domain-driven approach to designing microservices so that each service follows the general rule of doing just one thing.
دارم یه CDN ساده با Go مینویسم.
فایدهاش اینه که کارکردن با هدرها، کشینگ (اگه خواستید Redis)، فشردهسازی (برای من gzip) و کلی چیزهای دیگه رو یاد میگیرید.
https://github.com/muhammadmp97/TinyCDN
فایدهاش اینه که کارکردن با هدرها، کشینگ (اگه خواستید Redis)، فشردهسازی (برای من gzip) و کلی چیزهای دیگه رو یاد میگیرید.
https://github.com/muhammadmp97/TinyCDN
GitHub
GitHub - muhammadmp97/TinyCDN: Minimal CDN service with Redis caching and gzip support
Minimal CDN service with Redis caching and gzip support - muhammadmp97/TinyCDN
🔥4❤2👍1
یه باگ داشتم، متوجه شدم یه اشتباه عجیب کردم. این دو حالت رو ببینید:
وقتی که مقدار someVariable نال باشه، اولی مشکل ایجاد میکنه. چون خروجیها اینطور میشه:
دیگه اولی یه آرایهی خالی نیست.
var_dump([$someVariable]);
var_dump((array) $someVariable);
وقتی که مقدار someVariable نال باشه، اولی مشکل ایجاد میکنه. چون خروجیها اینطور میشه:
array(1) {
[0]=>
NULL
}
array(0) {
}دیگه اولی یه آرایهی خالی نیست.
👍4👎1🔥1
دو تا گوروتین که با هم ping pong بازی میکنند. :)
نکته: در برنامههای بدون پایان طبیعی، کانال را باز نگه میدارند و
#go
package main
import (
"fmt"
"time"
)
func main() {
ch := make(chan string)
go func() {
for msg := range ch {
if msg == "ping" {
time.Sleep(1 * time.Second)
fmt.Println("ping")
ch <- "pong"
} else {
ch <- msg
}
}
}()
go func() {
for msg := range ch {
if msg == "pong" {
time.Sleep(1 * time.Second)
fmt.Println("pong")
ch <- "ping"
} else {
ch <- msg
}
}
}()
ch <- "ping"
select {}
}
نکته: در برنامههای بدون پایان طبیعی، کانال را باز نگه میدارند و
main را با چیزی مثل select {} زنده نگه میدارند.#go
🔥2
Use Cases for Unbuffered Channels
- Synchronization: Enforcing that two goroutines execute in a specific order.
- Signaling: Indicating that a goroutine has completed a task or reached a certain state.
- Request-Response Patterns: Implementing simple request-response interactions between goroutines.
Use Cases for Buffered Channels
- Work Queues: Distributing work among multiple worker goroutines, allowing the sender to enqueue tasks without waiting for immediate processing.
- Rate Limiting: Controlling the rate at which data is processed by limiting the number of elements in the channel.
- Buffering Data Streams: Temporarily storing data from a fast producer before it is consumed by a slower consumer.
#go
- Synchronization: Enforcing that two goroutines execute in a specific order.
- Signaling: Indicating that a goroutine has completed a task or reached a certain state.
- Request-Response Patterns: Implementing simple request-response interactions between goroutines.
Use Cases for Buffered Channels
- Work Queues: Distributing work among multiple worker goroutines, allowing the sender to enqueue tasks without waiting for immediate processing.
- Rate Limiting: Controlling the rate at which data is processed by limiting the number of elements in the channel.
- Buffering Data Streams: Temporarily storing data from a fast producer before it is consumed by a slower consumer.
#go
اینجا کامنت گذاشتم. قربون مرامتون، اگه خوشتون اومد لایک کنید شاید از شر کیبورد فعلی راحت شدیم:
https://www.linkedin.com/posts/liara-cloud_%DA%86%D8%A7%D9%84%D8%B4-%D8%B3%D9%88%D9%85-activity-7388149509194797057-IRhQ
https://www.linkedin.com/posts/liara-cloud_%DA%86%D8%A7%D9%84%D8%B4-%D8%B3%D9%88%D9%85-activity-7388149509194797057-IRhQ
Linuxor ?
خوبی زبان PHP اینه که خیلی سادس، اما خطا هاش خیلی خوب توی مرورگر نشون داده نمیشن
مثلاً اونها که Go یا JS(Node.js) یا Python استفاده میکنند، خطاهاشون چطور نمایش داده میشه؟ اصلاً مگه نمایش گرافیکی خطا وظیفهی زبونه؟
👍1👎1