zen/schemas/proto/notify/v1/notify.proto

68 lines
2.2 KiB
Protocol Buffer

syntax = "proto3";
package notify.v1;
import "notify/v1/send_notification.proto";
service NotifyService {
// SendNotification sends notification data to Zen Server.
//
// Returns notification_id that can be used to send attachments.
//
// notification_id is long lived and can be given attachments even on the far future.
//
// If you want to send attachments, use SendAttachment rpc.
//
// `notification_id` respond can be used to send attachments via SendAttachment rpc.
// `upload_url` can be used to upload attachments via http protocol (fetch, axios, http post, etc).
rpc SendNotification(SendNotificationRequest) returns (SendNotificationResponse);
// SendAttachment sends attachment data to Zen Server.
//
// SendAttachment rpc is not supported by Browser Javascript.
//
// If implementing logic for SendAttachment rpc is difficult, consider using `upload_url`
// to upload attachments via http protocol.
//
// SendAttachment requires notification_id that was returned by SendNotification
// so that Zen server can associate attachment with notification.
//
// One Stream One Attachment. To send multiple attachments, spawn multiple streams by calling
// SendAttachment multiple times with the same notification_id and send chunks of data in order.
//
// PSEUDOCODE:
//
// response = client.SendNotification({
// payload: {...},
// resource: {...},
// })
//
// notification_id = response.notification_id
//
// for attachment in attachments {
// stream = client.SendAttachment()
// // thread.spawn is a pseudo code for creating a new thread or background worker/task.
// thread.spawn ({
// for chunk in attachment.chunks {
// stream.Send({
// notification_id: notification_id,
// name: attachment.name,
// content_type: attachment.content_type,
// chunk: chunk,
// })
// }
// stream.Close()
// })
// }
rpc SendAttachment(stream SendAttachmentRequest) returns (SendAttachmentResponse);
}
message SendAttachmentRequest {
string notification_id = 1;
string name = 2;
string content_type = 3;
bytes chunk = 4;
}
message SendAttachmentResponse {}