All Projects → xiaojiaoyu100 → aliyun-mns

xiaojiaoyu100 / aliyun-mns

Licence: MIT license
阿里云MNS

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to aliyun-mns

square-attack
Square Attack: a query-efficient black-box adversarial attack via random search [ECCV 2020]
Stars: ✭ 89 (+584.62%)
Mutual labels:  robustness
recentrifuge
Recentrifuge: robust comparative analysis and contamination removal for metagenomics
Stars: ✭ 79 (+507.69%)
Mutual labels:  robustness
Advances-in-Label-Noise-Learning
A curated (most recent) list of resources for Learning with Noisy Labels
Stars: ✭ 360 (+2669.23%)
Mutual labels:  robustness
angsd-wrapper
Utilities for analyzing next generation sequencing data.
Stars: ✭ 13 (+0%)
Mutual labels:  user-friendly
paperback
Paper backup generator suitable for long-term storage.
Stars: ✭ 517 (+3876.92%)
Mutual labels:  user-friendly
pre-training
Pre-Training Buys Better Robustness and Uncertainty Estimates (ICML 2019)
Stars: ✭ 90 (+592.31%)
Mutual labels:  robustness
adversarial-vision-challenge
NIPS Adversarial Vision Challenge
Stars: ✭ 39 (+200%)
Mutual labels:  robustness
fansly
Simply scrape / download all the media from an fansly account
Stars: ✭ 351 (+2600%)
Mutual labels:  user-friendly
Duf
Disk Usage/Free Utility - a better 'df' alternative
Stars: ✭ 7,240 (+55592.31%)
Mutual labels:  user-friendly
ViTs-vs-CNNs
[NeurIPS 2021]: Are Transformers More Robust Than CNNs? (Pytorch implementation & checkpoints)
Stars: ✭ 145 (+1015.38%)
Mutual labels:  robustness
GeneTonic
Enjoy your transcriptomic data and analysis responsibly - like sipping a cocktail
Stars: ✭ 66 (+407.69%)
Mutual labels:  user-friendly
ValliStart
A start menu to replace the un-customizable one that you have right now.
Stars: ✭ 89 (+584.62%)
Mutual labels:  user-friendly
spatial-smoothing
(ICML 2022) Official PyTorch implementation of “Blurs Behave Like Ensembles: Spatial Smoothings to Improve Accuracy, Uncertainty, and Robustness”.
Stars: ✭ 68 (+423.08%)
Mutual labels:  robustness
Comprehensive-Tacotron2
PyTorch Implementation of Google's Natural TTS Synthesis by Conditioning WaveNet on Mel Spectrogram Predictions. This implementation supports both single-, multi-speaker TTS and several techniques to enforce the robustness and efficiency of the model.
Stars: ✭ 22 (+69.23%)
Mutual labels:  robustness
Denoised-Smoothing-TF
Minimal implementation of Denoised Smoothing (https://arxiv.org/abs/2003.01908) in TensorFlow.
Stars: ✭ 19 (+46.15%)
Mutual labels:  robustness
GeFs
Generative Forests in Python
Stars: ✭ 23 (+76.92%)
Mutual labels:  robustness
vue-unsaved-changes-dialog
Beautiful unsaved changes dialog, inspired by a component from the Squarespace admin
Stars: ✭ 13 (+0%)
Mutual labels:  user-friendly
POPQORN
An Algorithm to Quantify Robustness of Recurrent Neural Networks
Stars: ✭ 44 (+238.46%)
Mutual labels:  robustness
SimP-GCN
Implementation of the WSDM 2021 paper "Node Similarity Preserving Graph Convolutional Networks"
Stars: ✭ 43 (+230.77%)
Mutual labels:  robustness
galaksio
An easy-to-use way for running Galaxy workflows.
Stars: ✭ 19 (+46.15%)
Mutual labels:  user-friendly

aliyun-mns

aliyun-mns是对阿里云消息服务的封装

GoDoc

队列模型

具有以下特点:

  • 动态创建队列
  • 可以设置消费者数目
  • 消息处理时长自适应
  • 发送消息重试。目前基于网络错误、阿里云MNS错误码表InternalError重试
  • 监控报警
  • 优雅的关闭消费者
  • 处理函数处理最大时间限制
  • 队列消费者使用协程池,每一个消息队列独占自己的协程池
  • 发送消息失败保存进入redis,尝试重新发送,提高发送成功率
  • 业务需要自己做消息幂等,有可能出现同样消息内容发送多次,这种情况非常罕见

消费者

package main

import (
	"context"
	"github.com/go-redis/redis/v7"
	"github.com/xiaojiaoyu100/aliyun-mns/v2"
)

type Builder struct {
}

func (b *Builder) Handle(ctx context.Context) error {
	//return alimns.BackoffError{
	//	Err:  err,
	//	N:  30,
	//}
	//return err 
	//return nil  
}

func Before(m *alimns.M) (context.Context, error) {
	return context.TODO(), nil
}

func After(ctx context.Context) {
}

func main() {
	option := &redis.Options{
		Addr: "127.0.0.1:6379",
		DB:   0,
	}

	redisClient := redis.NewClient(option)
	client, err := alimns.NewClient(alimns.Config{
		Cmdable:         redisClient,
		Endpoint:        "",
		QueuePrefix:     "", // 可以留空,表示拉取全部消息队列
		AccessKeyID:     "",
		AccessKeySecret: "",
	})
	if err != nil {
		return
	}

	client.SetBefore(Before)
	client.SetAfter(After)

	consumer := alimns.NewConsumer(client)
	err = consumer.AddQueue(
		&alimns.Queue{
			Name:     "QueueTest1",
			Builder:  &Builder{},
		},
	)
	if err != nil {
		return
	}
	consumer.Run()
}

生产者

producer := alimns.NewProducer(client)
producer.SendBase64EncodedJSONMessage()

主题模型

支持以下主题api:

  • 支持主题的创建,删除
  • 支持订阅主题,取消主题订阅
  • 支持向主题发布消息

创建/订阅主题

endpoint := QueueEndPoint{
	AccountID: "xxx",
	Region:    "xxx",
	QueueName: "xxx",
}

// 创建
err := client.CreateTopic("topicName")
if err != nil {
	return
}

// 订阅
err = client.Subscribe("topicName", "subscriptionName", endpoint)
if err != nil {
	return
}

发布消息

messageID, err := client.PublishMessage("topicName", "hello world")
if err != nil {
	return
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].