github.com/kaisenlinux/docker@v0.0.0-20230510090727-ea55db55fac7/swarmkit/api/watch.proto (about) 1 syntax = "proto3"; 2 3 package docker.swarmkit.v1; 4 5 import "github.com/docker/swarmkit/api/specs.proto"; 6 import "github.com/docker/swarmkit/api/objects.proto"; 7 import "github.com/docker/swarmkit/api/types.proto"; 8 import "gogoproto/gogo.proto"; 9 import "github.com/docker/swarmkit/protobuf/plugin/plugin.proto"; 10 11 message Object { 12 oneof Object { 13 Node node = 1; 14 Service service = 2; 15 Network network = 3; 16 Task task = 4; 17 Cluster cluster = 5; 18 Secret secret = 6; 19 Resource resource = 7; 20 Extension extension = 8; 21 Config config = 9; 22 } 23 } 24 25 // FIXME(aaronl): These messages should ideally be embedded in SelectBy, but 26 // protoc generates bad code for that. 27 message SelectBySlot { 28 string service_id = 1 [(gogoproto.customname) = "ServiceID"]; 29 uint64 slot = 2; 30 } 31 32 message SelectByCustom { 33 string kind = 1; 34 string index = 2; 35 string value = 3; 36 } 37 38 message SelectBy { 39 // TODO(aaronl): Are all of these things we want to expose in 40 // the API? Exposing them may commit us to maintaining those 41 // internal indices going forward. 42 oneof By { 43 // supported by all object types 44 string id = 1 [(gogoproto.customname) = "ID"]; // not applicable for FindObjects - use GetObject instead 45 string id_prefix = 2 [(gogoproto.customname) = "IDPrefix"]; 46 string name = 3; 47 string name_prefix = 4; 48 SelectByCustom custom = 5; 49 SelectByCustom custom_prefix = 6; 50 51 // supported by tasks only 52 string service_id = 7 [(gogoproto.customname) = "ServiceID"]; 53 string node_id = 8 [(gogoproto.customname) = "NodeID"]; 54 SelectBySlot slot = 9; 55 TaskState desired_state = 10; 56 57 // supported by nodes only 58 NodeRole role = 11; 59 NodeSpec.Membership membership = 12; 60 61 // supported by: service, task 62 string referenced_network_id = 13 [(gogoproto.customname) = "ReferencedNetworkID"]; 63 string referenced_secret_id = 14 [(gogoproto.customname) = "ReferencedSecretID"]; 64 string referenced_config_id = 16 [(gogoproto.customname) = "ReferencedConfigID"]; 65 66 // supported by: resource 67 string kind = 15; 68 } 69 } 70 71 72 // Watch defines the RPC methods for monitoring data store change. 73 service Watch { 74 // Watch starts a stream that returns any changes to objects that match 75 // the specified selectors. When the stream begins, it immediately sends 76 // an empty message back to the client. It is important to wait for 77 // this message before taking any actions that depend on an established 78 // stream of changes for consistency. 79 rpc Watch(WatchRequest) returns (stream WatchMessage) { 80 option (docker.protobuf.plugin.tls_authorization) = { roles: "swarm-manager" }; 81 }; 82 } 83 84 message WatchRequest { 85 message WatchEntry { 86 // Kind can contain a builtin type such as "node", "secret", etc. or 87 // the kind specified by a custom-defined object. 88 string kind = 1; 89 90 // Action (create/update/delete) 91 // This is a bitmask, so multiple actions may be OR'd together 92 WatchActionKind action = 2; 93 94 // Filters are combined using AND logic - an event must match 95 // all of them to pass the filter. 96 repeated SelectBy filters = 3; 97 } 98 99 // Multiple entries are combined using OR logic - i.e. if an event 100 // matches all of the selectors specified in any single watch entry, 101 // the event will be sent to the client. 102 repeated WatchEntry entries = 1; 103 104 // ResumeFrom provides an version to resume the watch from, if non-nil. 105 // The watch will return changes since this version, and continue to 106 // return new changes afterwards. Watch will return an error if the 107 // server has compacted its log and no longer has complete history to 108 // this point. 109 Version resume_from = 2; 110 111 // IncludeOldObject causes WatchMessages to include a copy of the 112 // previous version of the object on updates. Note that only live 113 // changes will include the old object (not historical changes 114 // retrieved using ResumeFrom). 115 bool include_old_object = 3; 116 } 117 118 // WatchMessage is the type of the stream that's returned to the client by 119 // Watch. Note that the first item of this stream will always be a WatchMessage 120 // with a nil Object, to signal that the stream has started. 121 message WatchMessage { 122 message Event { 123 // Action (create/update/delete) 124 // Note that WatchMessage does not expose "commit" events that 125 // mark transaction boundaries. 126 WatchActionKind action = 1; 127 128 // Matched object 129 Object object = 2; 130 131 // For updates, OldObject will optionally be included in the 132 // watch message, containing the previous version of the 133 // object, if IncludeOldObject was set in WatchRequest. 134 Object old_object = 3; 135 } 136 137 repeated Event events = 1; 138 139 // Index versions this change to the data store. It can be used to 140 // resume the watch from this point. 141 Version version = 2; 142 } 143 144 // WatchActionKind distinguishes between creations, updates, and removals. It 145 // is structured as a bitmap so multiple kinds of events can be requested with 146 // a mask. 147 enum WatchActionKind { 148 option (gogoproto.goproto_enum_prefix) = false; 149 option (gogoproto.enum_customname) = "WatchActionKind"; 150 WATCH_ACTION_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "WatchActionKindUnknown"]; // default value, invalid 151 WATCH_ACTION_CREATE = 1 [(gogoproto.enumvalue_customname) = "WatchActionKindCreate"]; 152 WATCH_ACTION_UPDATE = 2 [(gogoproto.enumvalue_customname) = "WatchActionKindUpdate"]; 153 WATCH_ACTION_REMOVE = 4 [(gogoproto.enumvalue_customname) = "WatchActionKindRemove"]; 154 }