Bump to containerd v1.0.0

Since that bumps to gogo protobuf v0.5 too do the same.

Note that there are no actual containerd changes here, although there are some
gogo proto ones.

Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
Ian Campbell 2017-12-01 14:56:55 +00:00
parent ebd7228a44
commit 12629fcb96
20 changed files with 270 additions and 174 deletions

View File

@ -1,11 +1,11 @@
github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403 github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403
github.com/containerd/containerd v1.0.0-beta.2 github.com/containerd/containerd v1.0.0
github.com/docker/distribution 3800056b8832cf6075e78b282ac010131d8687bc github.com/docker/distribution 3800056b8832cf6075e78b282ac010131d8687bc
github.com/docker/docker ba99c19b593bdb9e7b90793681fe89b0a91781ed github.com/docker/docker ba99c19b593bdb9e7b90793681fe89b0a91781ed
github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06 github.com/docker/go d30aec9fd63c35133f8f79c3412ad91a3b08be06
github.com/docker/go-connections v0.3.0 github.com/docker/go-connections v0.3.0
github.com/docker/go-units v0.3.1 github.com/docker/go-units v0.3.1
github.com/gogo/protobuf v0.4 github.com/gogo/protobuf v0.5
github.com/gorilla/mux 4c1c3952b7d9d0a061a3fa7b36fd373ba0398ebc github.com/gorilla/mux 4c1c3952b7d9d0a061a3fa7b36fd373ba0398ebc
github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448 github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448
github.com/opencontainers/image-spec v1.0.0 github.com/opencontainers/image-spec v1.0.0

View File

@ -1,4 +1,4 @@
Attribution-ShareAlike 4.0 International Attribution 4.0 International
======================================================================= =======================================================================
@ -54,18 +54,16 @@ exhaustive, and do not form part of our licenses.
======================================================================= =======================================================================
Creative Commons Attribution-ShareAlike 4.0 International Public Creative Commons Attribution 4.0 International Public License
License
By exercising the Licensed Rights (defined below), You accept and agree By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons to be bound by the terms and conditions of this Creative Commons
Attribution-ShareAlike 4.0 International Public License ("Public Attribution 4.0 International Public License ("Public License"). To the
License"). To the extent this Public License may be interpreted as a extent this Public License may be interpreted as a contract, You are
contract, You are granted the Licensed Rights in consideration of Your granted the Licensed Rights in consideration of Your acceptance of
acceptance of these terms and conditions, and the Licensor grants You these terms and conditions, and the Licensor grants You such rights in
such rights in consideration of benefits the Licensor receives from consideration of benefits the Licensor receives from making the
making the Licensed Material available under these terms and Licensed Material available under these terms and conditions.
conditions.
Section 1 -- Definitions. Section 1 -- Definitions.
@ -84,11 +82,7 @@ Section 1 -- Definitions.
and Similar Rights in Your contributions to Adapted Material in and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License. accordance with the terms and conditions of this Public License.
c. BY-SA Compatible License means a license listed at c. Copyright and Similar Rights means copyright and/or similar rights
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
d. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation, closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or Rights, without regard to how the rights are labeled or
@ -96,33 +90,29 @@ Section 1 -- Definitions.
specified in Section 2(b)(1)-(2) are not Copyright and Similar specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights. Rights.
e. Effective Technological Measures means those measures that, in the d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international Treaty adopted on December 20, 1996, and/or similar international
agreements. agreements.
f. Exceptions and Limitations means fair use, fair dealing, and/or e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material. that applies to Your use of the Licensed Material.
g. License Elements means the license attributes listed in the name f. Licensed Material means the artistic or literary work, database,
of a Creative Commons Public License. The License Elements of this
Public License are Attribution and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public or other material to which the Licensor applied this Public
License. License.
i. Licensed Rights means the rights granted to You subject to the g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license. Licensed Material and that the Licensor has authority to license.
j. Licensor means the individual(s) or entity(ies) granting rights h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License. under this Public License.
k. Share means to provide material to the public by any means or i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution, as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material dissemination, communication, or importation, and to make material
@ -130,13 +120,13 @@ Section 1 -- Definitions.
public may access the material from a place and at a time public may access the material from a place and at a time
individually chosen by them. individually chosen by them.
l. Sui Generis Database Rights means rights other than copyright j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases, the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world. equivalent rights anywhere in the world.
m. You means the individual or entity exercising the Licensed Rights k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning. under this Public License. Your has a corresponding meaning.
@ -182,13 +172,7 @@ Section 2 -- Scope.
Licensed Rights under the terms and conditions of this Licensed Rights under the terms and conditions of this
Public License. Public License.
b. Additional offer from the Licensor -- Adapted Material. b. No downstream restrictions. You may not offer or impose
Every recipient of Adapted Material from You
automatically receives an offer from the Licensor to
exercise the Licensed Rights in the Adapted Material
under the conditions of the Adapter's License You apply.
c. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the Licensed Material if doing so restricts exercise of the
@ -270,24 +254,9 @@ following conditions.
information required by Section 3(a)(1)(A) to the extent information required by Section 3(a)(1)(A) to the extent
reasonably practicable. reasonably practicable.
b. ShareAlike. 4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
In addition to the conditions in Section 3(a), if You Share Material from complying with this Public License.
Adapted Material You produce, the following conditions also apply.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
in any reasonable manner based on the medium, means, and
context in which You Share Adapted Material.
3. You may not offer or impose any additional or different terms
or conditions on, or apply any Effective Technological
Measures to, Adapted Material that restrict exercise of the
rights granted under the Adapter's License You apply.
Section 4 -- Sui Generis Database Rights. Section 4 -- Sui Generis Database Rights.
@ -302,9 +271,8 @@ apply to Your use of the Licensed Material:
b. if You include all or a substantial portion of the database b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material, Rights (but not its individual contents) is Adapted Material; and
including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database. all or a substantial portion of the contents of the database.
@ -407,11 +375,13 @@ Section 8 -- Interpretation.
======================================================================= =======================================================================
Creative Commons is not a party to its public licenses. Creative Commons is not a party to its public
Notwithstanding, Creative Commons may elect to apply one of its public licenses. Notwithstanding, Creative Commons may elect to apply one of
licenses to material it publishes and in those instances will be its public licenses to material it publishes and in those instances
considered the "Licensor." Except for the limited purpose of indicating will be considered the “Licensor.” The text of the Creative Commons
that material is shared under a Creative Commons public license or as public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo use of the trademark "Creative Commons" or any other trademark or logo
@ -419,7 +389,7 @@ of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements, to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the public the avoidance of doubt, this paragraph does not form part of the
licenses. public licenses.
Creative Commons may be contacted at creativecommons.org. Creative Commons may be contacted at creativecommons.org.

View File

@ -13,7 +13,37 @@ containerd is designed to be embedded into a larger system, rather than being us
## Getting Started ## Getting Started
If you are interested in trying out containerd please see our [Getting Started Guide](docs/getting-started.md). See our documentation on [containerd.io](containerd.io):
* [for ops and admins](docs/ops.md)
* [namespaces](docs/namespaces.md)
* [client options](docs/client-opts.md)
See how to build containerd from source at [BUILDING](BUILDING.md).
If you are interested in trying out containerd see our example at [Getting Started](docs/getting-started.md).
## Runtime Requirements
Runtime requirements for containerd are very minimal. Most interactions with
the Linux and Windows container feature sets are handled via [runc](https://github.com/opencontainers/runc) and/or
OS-specific libraries (e.g. [hcsshim](https://github.com/Microsoft/hcsshim) for Microsoft). The current required version of `runc` is always listed in [RUNC.md](/RUNC.md).
There are specific features
used by containerd core code and snapshotters that will require a minimum kernel
version on Linux. With the understood caveat of distro kernel versioning, a
reasonable starting point for Linux is a minimum 4.x kernel version.
The overlay filesystem snapshotter, used by default, uses features that were
finalized in the 4.x kernel series. If you choose to use btrfs, there may
be more flexibility in kernel version (minimum recommended is 3.18), but will
require the btrfs kernel module and btrfs tools to be installed on your Linux
distribution.
To use Linux checkpoint and restore features, you will need `criu` installed on
your system. See more details in [Checkpoint and Restore](#checkpoint-and-restore).
Build requirements for developers are listed in [BUILDING](BUILDING.md).
## Features ## Features
@ -23,7 +53,11 @@ containerd offers a full client package to help you integrate containerd into yo
```go ```go
import "github.com/containerd/containerd" import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
)
func main() { func main() {
client, err := containerd.New("/run/containerd/containerd.sock") client, err := containerd.New("/run/containerd/containerd.sock")
@ -39,7 +73,7 @@ Namespaces allow multiple consumers to use the same containerd without conflicti
To set a namespace for requests to the API: To set a namespace for requests to the API:
```go ```go
context = context.Background() context = context.Background()
// create a context for docker // create a context for docker
docker = namespaces.WithNamespace(context, "docker") docker = namespaces.WithNamespace(context, "docker")
@ -78,7 +112,7 @@ containerd fully supports the OCI runtime specification for running containers.
You can specify options when creating a container about how to modify the specification. You can specify options when creating a container about how to modify the specification.
```go ```go
redis, err := client.NewContainer(context, "redis-master", containerd.WithNewSpec(containerd.WithImageConfig(image))) redis, err := client.NewContainer(context, "redis-master", containerd.WithNewSpec(oci.WithImageConfig(image)))
``` ```
### Root Filesystems ### Root Filesystems
@ -92,8 +126,7 @@ image, err := client.Pull(context, "docker.io/library/redis:latest", containerd.
// allocate a new RW root filesystem for a container based on the image // allocate a new RW root filesystem for a container based on the image
redis, err := client.NewContainer(context, "redis-master", redis, err := client.NewContainer(context, "redis-master",
containerd.WithNewSnapshot("redis-rootfs", image), containerd.WithNewSnapshot("redis-rootfs", image),
containerd.WithNewSpec(containerd.WithImageConfig(image)), containerd.WithNewSpec(oci.WithImageConfig(image)),
) )
// use a readonly filesystem with multiple containers // use a readonly filesystem with multiple containers
@ -101,7 +134,7 @@ for i := 0; i < 10; i++ {
id := fmt.Sprintf("id-%s", i) id := fmt.Sprintf("id-%s", i)
container, err := client.NewContainer(ctx, id, container, err := client.NewContainer(ctx, id,
containerd.WithNewSnapshotView(id, image), containerd.WithNewSnapshotView(id, image),
containerd.WithNewSpec(containerd.WithImageConfig(image)), containerd.WithNewSpec(oci.WithImageConfig(image)),
) )
} }
``` ```
@ -112,7 +145,7 @@ Taking a container object and turning it into a runnable process on a system is
```go ```go
// create a new task // create a new task
task, err := redis.NewTask(context, containerd.Stdio) task, err := redis.NewTask(context, cio.Stdio)
defer task.Delete(context) defer task.Delete(context)
// the task is now running and has a pid that can be use to setup networking // the task is now running and has a pid that can be use to setup networking
@ -144,37 +177,12 @@ checkpoint := image.Target()
redis, err = client.NewContainer(context, "redis-master", containerd.WithCheckpoint(checkpoint, "redis-rootfs")) redis, err = client.NewContainer(context, "redis-master", containerd.WithCheckpoint(checkpoint, "redis-rootfs"))
defer container.Delete(context) defer container.Delete(context)
task, err = redis.NewTask(context, containerd.Stdio, containerd.WithTaskCheckpoint(checkpoint)) task, err = redis.NewTask(context, cio.Stdio, containerd.WithTaskCheckpoint(checkpoint))
defer task.Delete(context) defer task.Delete(context)
err := task.Start(context) err := task.Start(context)
``` ```
## Developer Quick-Start
To build the daemon and `ctr` simple test client, the following build system dependencies are required:
* Go 1.8.x or above (requires 1.8 due to use of golang plugin(s))
* Protoc 3.x compiler and headers (download at the [Google protobuf releases page](https://github.com/google/protobuf/releases))
* Btrfs headers and libraries for your distribution. Note that building the btrfs driver can be disabled via build tag removing this dependency.
For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.1.0 release for a 64-bit Linux host:
```
$ wget -c https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip
$ sudo unzip protoc-3.1.0-linux-x86_64.zip -d /usr/local
```
With the required dependencies installed, the `Makefile` target named **binaries** will compile the `ctr` and `containerd` binaries and place them in the `bin/` directory. Using `sudo make install` will place the binaries in `/usr/local/bin`. When making any changes to the gRPC API, `make generate` will use the installed `protoc` compiler to regenerate the API generated code packages.
> *Note*: A build tag is currently available to disable building the btrfs snapshot driver.
> Adding `BUILDTAGS=no_btrfs` to your environment before calling the **binaries**
> Makefile target will disable the btrfs driver within the containerd Go build.
Vendoring of external imports uses the [`vndr` tool](https://github.com/LK4D4/vndr) which uses a simple config file, `vendor.conf`, to provide the URL and version or hash details for each vendored import. After modifying `vendor.conf` run the `vndr` tool to update the `vendor/` directory contents. Combining the `vendor.conf` update with the changeset in `vendor/` after running `vndr` should become a single commit for a PR which relies on vendored updates.
Please refer to [RUNC.md](/RUNC.md) for the currently supported version of `runc` that is used by containerd.
### Releases and API Stability ### Releases and API Stability
Please see [RELEASES.md](RELEASES.md) for details on versioning and stability Please see [RELEASES.md](RELEASES.md) for details on versioning and stability
@ -196,13 +204,12 @@ For sync communication we have a community slack with a #containerd channel that
### Reporting security issues ### Reporting security issues
__If you are reporting a security issue, please reach out discreetly at containerd-security@googlegroups.com__. __If you are reporting a security issue, please reach out discreetly at security@containerd.io__.
## Copyright and license ## Licenses
Copyright ©2016-2017 Docker, Inc. All rights reserved, except as follows. Code The containerd codebase is released under the [Apache 2.0 license](LICENSE.code).
is released under the Apache 2.0 license. The README.md file, and files in the The README.md file, and files in the "docs" folder are licensed under the
"docs" folder are licensed under the Creative Commons Attribution 4.0 Creative Commons Attribution 4.0 International License under the terms and
International License under the terms and conditions set forth in the file conditions set forth in the file "[LICENSE.docs](LICENSE.docs)". You may obtain a duplicate
"LICENSE.docs". You may obtain a duplicate copy of the same license, titled copy of the same license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.
CC-BY-SA-4.0, at http://creativecommons.org/licenses/by/4.0/.

View File

@ -1,7 +1,7 @@
github.com/coreos/go-systemd 48702e0da86bd25e76cfef347e2adeb434a0d0a6 github.com/coreos/go-systemd 48702e0da86bd25e76cfef347e2adeb434a0d0a6
github.com/containerd/go-runc 633fd07c086ff591adaa2849278764771d791f6f github.com/containerd/go-runc ed1cbe1fc31f5fb2359d3a54b6330d1a097858b7
github.com/containerd/console 84eeaae905fa414d03e07bcd6c8d3f19e7cf180e github.com/containerd/console 84eeaae905fa414d03e07bcd6c8d3f19e7cf180e
github.com/containerd/cgroups 9c238e632e80d94f71a067c3deb9b34b1886ef18 github.com/containerd/cgroups 29da22c6171a4316169f9205ab6c49f59b5b852f
github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788
github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87 github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
@ -13,19 +13,19 @@ github.com/prometheus/procfs fcdb11ccb4389efb1b210b7ffb623ab71c5fdd60
github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
github.com/matttproud/golang_protobuf_extensions v1.0.0 github.com/matttproud/golang_protobuf_extensions v1.0.0
github.com/docker/go-units v0.3.1 github.com/docker/go-units v0.3.1
github.com/gogo/protobuf d2e1ade2d719b78fe5b061b4c18a9f7111b5bdc8 github.com/gogo/protobuf v0.5
github.com/golang/protobuf 5a0f697c9ed9d68fef0116532c6e05cfeae00e55 github.com/golang/protobuf 1643683e1b54a9e88ad26d98f81400c8c9d9f4f9
github.com/opencontainers/runtime-spec v1.0.0 github.com/opencontainers/runtime-spec v1.0.0
github.com/opencontainers/runc 0351df1c5a66838d0c392b4ac4cf9450de844e2d github.com/opencontainers/runc 74a17296470088de3805e138d3d87c62e613dfc4
github.com/sirupsen/logrus v1.0.0 github.com/sirupsen/logrus v1.0.0
github.com/containerd/btrfs cc52c4dea2ce11a44e6639e561bb5c2af9ada9e3 github.com/containerd/btrfs cc52c4dea2ce11a44e6639e561bb5c2af9ada9e3
github.com/stretchr/testify v1.1.4 github.com/stretchr/testify v1.1.4
github.com/davecgh/go-spew v1.1.0 github.com/davecgh/go-spew v1.1.0
github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib v1.0.0
github.com/containerd/fifo fbfb6a11ec671efbe94ad1c12c2e98773f19e1e6 github.com/containerd/fifo fbfb6a11ec671efbe94ad1c12c2e98773f19e1e6
github.com/urfave/cli 8ba6f23b6e36d03666a14bd9421f5e3efcb59aca github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6
google.golang.org/grpc v1.3.0 google.golang.org/grpc v1.7.2
github.com/pkg/errors v0.8.0 github.com/pkg/errors v0.8.0
github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448 github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448
golang.org/x/sys 314a259e304ff91bd6985da2a7149bbf91237993 https://github.com/golang/sys golang.org/x/sys 314a259e304ff91bd6985da2a7149bbf91237993 https://github.com/golang/sys
@ -35,9 +35,10 @@ golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
github.com/BurntSushi/toml v0.2.0-21-g9906417 github.com/BurntSushi/toml v0.2.0-21-g9906417
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0 github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
github.com/Microsoft/go-winio v0.4.4 github.com/Microsoft/go-winio v0.4.4
github.com/Microsoft/hcsshim v0.6.3 github.com/Microsoft/hcsshim v0.6.7
github.com/Microsoft/opengcs v0.3.2 github.com/Microsoft/opengcs v0.3.2
github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4 golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
github.com/dmcgowan/go-tar 2e2c51242e8993c50445dab7c03c8e7febddd0cf github.com/dmcgowan/go-tar go1.10
github.com/stevvooe/ttrpc 76e68349ad9ab4d03d764c713826d31216715e4f

View File

@ -25,7 +25,7 @@ To use this software, you must:
for details or, if you are using gccgo, follow the instructions at for details or, if you are using gccgo, follow the instructions at
https://golang.org/doc/install/gccgo https://golang.org/doc/install/gccgo
- Grab the code from the repository and install the proto package. - Grab the code from the repository and install the proto package.
The simplest way is to run `go get -u github.com/golang/protobuf/{proto,protoc-gen-go}`. The simplest way is to run `go get -u github.com/golang/protobuf/protoc-gen-go`.
The compiler plugin, protoc-gen-go, will be installed in $GOBIN, The compiler plugin, protoc-gen-go, will be installed in $GOBIN,
defaulting to $GOPATH/bin. It must be in your $PATH for the protocol defaulting to $GOPATH/bin. It must be in your $PATH for the protocol
compiler, protoc, to find it. compiler, protoc, to find it.
@ -118,7 +118,6 @@ for a protocol buffer variable v:
When the .proto file specifies `syntax="proto3"`, there are some differences: When the .proto file specifies `syntax="proto3"`, there are some differences:
- Non-repeated fields of non-message type are values instead of pointers. - Non-repeated fields of non-message type are values instead of pointers.
- Getters are only generated for message and oneof fields.
- Enum types do not get an Enum method. - Enum types do not get an Enum method.
Consider file test.proto, containing Consider file test.proto, containing

View File

@ -38,14 +38,19 @@ These projects use gogoprotobuf:
- <a href="https://github.com/docker/swarmkit">docker swarmkit</a> - <a href="https://github.com/docker/swarmkit/blob/63600e01af3b8da2a0ed1c9fa6e1ae4299d75edb/api/objects.proto">sample proto file</a> - <a href="https://github.com/docker/swarmkit">docker swarmkit</a> - <a href="https://github.com/docker/swarmkit/blob/63600e01af3b8da2a0ed1c9fa6e1ae4299d75edb/api/objects.proto">sample proto file</a>
- <a href="https://nats.io/">nats.io</a> - <a href="https://github.com/nats-io/go-nats-streaming/blob/master/pb/protocol.proto">go-nats-streaming</a> - <a href="https://nats.io/">nats.io</a> - <a href="https://github.com/nats-io/go-nats-streaming/blob/master/pb/protocol.proto">go-nats-streaming</a>
- <a href="https://github.com/pingcap/tidb">tidb</a> - Communication between <a href="https://github.com/pingcap/tipb/blob/master/generate-go.sh#L4">tidb</a> and <a href="https://github.com/pingcap/kvproto/blob/master/generate_go.sh#L3">tikv</a> - <a href="https://github.com/pingcap/tidb">tidb</a> - Communication between <a href="https://github.com/pingcap/tipb/blob/master/generate-go.sh#L4">tidb</a> and <a href="https://github.com/pingcap/kvproto/blob/master/generate_go.sh#L3">tikv</a>
- <a href="https://github.com/AsynkronIT/protoactor-go">protoactor-go</a> - <a href="https://github.com/AsynkronIT/protoactor-go/blob/dev/protobuf/protoc-gen-protoactor/main.go">vanity command</a> that also generates actors from service definitions - <a href="https://github.com/AsynkronIT/protoactor-go">protoactor-go</a> - <a href="https://github.com/AsynkronIT/protoactor-go/blob/master/protobuf/protoc-gen-protoactor/main.go">vanity command</a> that also generates actors from service definitions
- <a href="https://containerd.io/">containerd</a> - <a href="https://github.com/containerd/containerd/tree/master/cmd/protoc-gen-gogoctrd">vanity command with custom field names</a> that conforms to the golang convention.
Please lets us know if you are using gogoprotobuf by posting on our <a href="https://groups.google.com/forum/#!topic/gogoprotobuf/Brw76BxmFpQ">GoogleGroup</a>. - <a href="https://github.com/heroiclabs/nakama">nakama</a>
- <a href="https://github.com/src-d/proteus">proteus</a>
- <a href="https://github.com/go-graphite">carbonzipper stack</a>
- <a href="https://sendgrid.com/">SendGrid</a>
Please let us know if you are using gogoprotobuf by posting on our <a href="https://groups.google.com/forum/#!topic/gogoprotobuf/Brw76BxmFpQ">GoogleGroup</a>.
### Mentioned ### Mentioned
- <a href="http://www.slideshare.net/albertstrasheim/serialization-in-go">Cloudflare - go serialization talk - Albert Strasheim</a> - <a href="http://www.slideshare.net/albertstrasheim/serialization-in-go">Cloudflare - go serialization talk - Albert Strasheim</a>
- <a href="http://gophercon.sourcegraph.com/post/83747547505/writing-a-high-performance-database-in-go">gophercon</a> - <a href="https://youtu.be/4xB46Xl9O9Q?t=557">GopherCon 2014 Writing High Performance Databases in Go by Ben Johnson</a>
- <a href="https://github.com/alecthomas/go_serialization_benchmarks">alecthomas' go serialization benchmarks</a> - <a href="https://github.com/alecthomas/go_serialization_benchmarks">alecthomas' go serialization benchmarks</a>
## Getting Started ## Getting Started
@ -59,10 +64,10 @@ After that you can choose:
### Installation ### Installation
To install it, you must first have Go (at least version 1.6.3) installed (see [http://golang.org/doc/install](http://golang.org/doc/install)). Go 1.7.1 and 1.8 is continuously tested. To install it, you must first have Go (at least version 1.6.3) installed (see [http://golang.org/doc/install](http://golang.org/doc/install)). Go 1.8.3 and 1.9 are continuously tested.
Next, install the standard protocol buffer implementation from [https://github.com/google/protobuf](https://github.com/google/protobuf). Next, install the standard protocol buffer implementation from [https://github.com/google/protobuf](https://github.com/google/protobuf).
Most versions from 2.3.1 should not give any problems, but 2.6.1, 3.0.2 and 3.1.0 are continuously tested. Most versions from 2.3.1 should not give any problems, but 2.6.1, 3.0.2 and 3.4.0 are continuously tested.
### Speed ### Speed

View File

@ -174,11 +174,11 @@ func sizeFixed32(x uint64) int {
// This is the format used for the sint64 protocol buffer type. // This is the format used for the sint64 protocol buffer type.
func (p *Buffer) EncodeZigzag64(x uint64) error { func (p *Buffer) EncodeZigzag64(x uint64) error {
// use signed number to get arithmetic right shift. // use signed number to get arithmetic right shift.
return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return p.EncodeVarint((x << 1) ^ uint64((int64(x) >> 63)))
} }
func sizeZigzag64(x uint64) int { func sizeZigzag64(x uint64) int {
return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return sizeVarint((x << 1) ^ uint64((int64(x) >> 63)))
} }
// EncodeZigzag32 writes a zigzag-encoded 32-bit integer // EncodeZigzag32 writes a zigzag-encoded 32-bit integer

View File

@ -73,7 +73,6 @@ for a protocol buffer variable v:
When the .proto file specifies `syntax="proto3"`, there are some differences: When the .proto file specifies `syntax="proto3"`, there are some differences:
- Non-repeated fields of non-message type are values instead of pointers. - Non-repeated fields of non-message type are values instead of pointers.
- Getters are only generated for message and oneof fields.
- Enum types do not get an Enum method. - Enum types do not get an Enum method.
The simplest way to describe this is to see an example. The simplest way to describe this is to see an example.

View File

@ -193,6 +193,7 @@ type Properties struct {
Default string // default value Default string // default value
HasDefault bool // whether an explicit default was provided HasDefault bool // whether an explicit default was provided
CustomType string CustomType string
CastType string
StdTime bool StdTime bool
StdDuration bool StdDuration bool
@ -341,6 +342,8 @@ func (p *Properties) Parse(s string) {
p.OrigName = strings.Split(f, "=")[1] p.OrigName = strings.Split(f, "=")[1]
case strings.HasPrefix(f, "customtype="): case strings.HasPrefix(f, "customtype="):
p.CustomType = strings.Split(f, "=")[1] p.CustomType = strings.Split(f, "=")[1]
case strings.HasPrefix(f, "casttype="):
p.CastType = strings.Split(f, "=")[1]
case f == "stdtime": case f == "stdtime":
p.StdTime = true p.StdTime = true
case f == "stdduration": case f == "stdduration":

View File

@ -522,6 +522,17 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
} }
return nil return nil
} }
} else if len(props.CastType) > 0 {
if _, ok := v.Interface().(interface {
String() string
}); ok {
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
_, err := fmt.Fprintf(w, "%d", v.Interface())
return err
}
}
} else if props.StdTime { } else if props.StdTime {
t, ok := v.Interface().(time.Time) t, ok := v.Interface().(time.Time)
if !ok { if !ok {
@ -531,9 +542,9 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
if err != nil { if err != nil {
return err return err
} }
props.StdTime = false propsCopy := *props // Make a copy so that this is goroutine-safe
err = tm.writeAny(w, reflect.ValueOf(tproto), props) propsCopy.StdTime = false
props.StdTime = true err = tm.writeAny(w, reflect.ValueOf(tproto), &propsCopy)
return err return err
} else if props.StdDuration { } else if props.StdDuration {
d, ok := v.Interface().(time.Duration) d, ok := v.Interface().(time.Duration)
@ -541,9 +552,9 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
return fmt.Errorf("stdtime is not time.Duration, but %T", v.Interface()) return fmt.Errorf("stdtime is not time.Duration, but %T", v.Interface())
} }
dproto := durationProto(d) dproto := durationProto(d)
props.StdDuration = false propsCopy := *props // Make a copy so that this is goroutine-safe
err := tm.writeAny(w, reflect.ValueOf(dproto), props) propsCopy.StdDuration = false
props.StdDuration = true err := tm.writeAny(w, reflect.ValueOf(dproto), &propsCopy)
return err return err
} }
} }

View File

@ -983,7 +983,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
return p.readStruct(fv, terminator) return p.readStruct(fv, terminator)
case reflect.Uint32: case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
fv.SetUint(uint64(x)) fv.SetUint(x)
return nil return nil
} }
case reflect.Uint64: case reflect.Uint64:

View File

@ -37,7 +37,6 @@ option go_package = "types";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto"; option java_outer_classname = "AnyProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// `Any` contains an arbitrary serialized protocol buffer message along with a // `Any` contains an arbitrary serialized protocol buffer message along with a
@ -75,6 +74,16 @@ option objc_class_prefix = "GPB";
// any.Unpack(foo) // any.Unpack(foo)
// ... // ...
// //
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use // The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack // 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/' // methods only use the fully qualified type name after the last '/'

View File

@ -53,6 +53,16 @@ option go_package = "plugin_go";
import "google/protobuf/descriptor.proto"; import "google/protobuf/descriptor.proto";
// The version number of protocol compiler.
message Version {
optional int32 major = 1;
optional int32 minor = 2;
optional int32 patch = 3;
// A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
// be empty for mainline stable releases.
optional string suffix = 4;
}
// An encoded CodeGeneratorRequest is written to the plugin's stdin. // An encoded CodeGeneratorRequest is written to the plugin's stdin.
message CodeGeneratorRequest { message CodeGeneratorRequest {
// The .proto files that were explicitly listed on the command-line. The // The .proto files that were explicitly listed on the command-line. The
@ -74,7 +84,14 @@ message CodeGeneratorRequest {
// the entire set into memory at once. However, as of this writing, this // the entire set into memory at once. However, as of this writing, this
// is not similarly optimized on protoc's end -- it will store all fields in // is not similarly optimized on protoc's end -- it will store all fields in
// memory at once before sending them to the plugin. // memory at once before sending them to the plugin.
//
// Type names of fields and extensions in the FileDescriptorProto are always
// fully qualified.
repeated FileDescriptorProto proto_file = 15; repeated FileDescriptorProto proto_file = 15;
// The version number of protocol compiler.
optional Version compiler_version = 3;
} }
// The plugin writes an encoded CodeGeneratorResponse to stdout. // The plugin writes an encoded CodeGeneratorResponse to stdout.

View File

@ -45,7 +45,6 @@ option java_package = "com.google.protobuf";
option java_outer_classname = "DescriptorProtos"; option java_outer_classname = "DescriptorProtos";
option csharp_namespace = "Google.Protobuf.Reflection"; option csharp_namespace = "Google.Protobuf.Reflection";
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
option java_generate_equals_and_hash = true;
// descriptor.proto must be optimized for speed because reflection-based // descriptor.proto must be optimized for speed because reflection-based
// algorithms don't work during bootstrapping. // algorithms don't work during bootstrapping.
@ -102,6 +101,8 @@ message DescriptorProto {
message ExtensionRange { message ExtensionRange {
optional int32 start = 1; optional int32 start = 1;
optional int32 end = 2; optional int32 end = 2;
optional ExtensionRangeOptions options = 3;
} }
repeated ExtensionRange extension_range = 5; repeated ExtensionRange extension_range = 5;
@ -122,6 +123,14 @@ message DescriptorProto {
repeated string reserved_name = 10; repeated string reserved_name = 10;
} }
message ExtensionRangeOptions {
// The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999;
// Clients can define custom options in extensions of this message. See above.
extensions 1000 to max;
}
// Describes a field within a message. // Describes a field within a message.
message FieldDescriptorProto { message FieldDescriptorProto {
enum Type { enum Type {
@ -140,7 +149,11 @@ message FieldDescriptorProto {
TYPE_FIXED32 = 7; TYPE_FIXED32 = 7;
TYPE_BOOL = 8; TYPE_BOOL = 8;
TYPE_STRING = 9; TYPE_STRING = 9;
TYPE_GROUP = 10; // Tag-delimited aggregate. // Tag-delimited aggregate.
// Group type is deprecated and not supported in proto3. However, Proto3
// implementations should still be able to parse the group wire format and
// treat group fields as unknown fields.
TYPE_GROUP = 10;
TYPE_MESSAGE = 11; // Length-delimited aggregate. TYPE_MESSAGE = 11; // Length-delimited aggregate.
// New in version 2. // New in version 2.
@ -158,7 +171,6 @@ message FieldDescriptorProto {
LABEL_OPTIONAL = 1; LABEL_OPTIONAL = 1;
LABEL_REQUIRED = 2; LABEL_REQUIRED = 2;
LABEL_REPEATED = 3; LABEL_REPEATED = 3;
// TODO(sanjay): Should we add LABEL_MAP?
}; };
optional string name = 1; optional string name = 1;
@ -306,19 +318,8 @@ message FileOptions {
// top-level extensions defined in the file. // top-level extensions defined in the file.
optional bool java_multiple_files = 10 [default=false]; optional bool java_multiple_files = 10 [default=false];
// If set true, then the Java code generator will generate equals() and // This option does nothing.
// hashCode() methods for all messages defined in the .proto file. optional bool java_generate_equals_and_hash = 20 [deprecated=true];
// This increases generated code size, potentially substantially for large
// protos, which may harm a memory-constrained application.
// - In the full runtime this is a speed optimization, as the
// AbstractMessage base class includes reflection-based implementations of
// these methods.
// - In the lite runtime, setting this option changes the semantics of
// equals() and hashCode() to more closely match those of the full runtime;
// the generated methods compute their results based on field values rather
// than object identity. (Implementations should not assume that hashcodes
// will be consistent across runtimes or versions of the protocol compiler.)
optional bool java_generate_equals_and_hash = 20 [default=false];
// If set true, then the Java2 code generator will generate code that // If set true, then the Java2 code generator will generate code that
// throws an exception whenever an attempt is made to assign a non-UTF-8 // throws an exception whenever an attempt is made to assign a non-UTF-8
@ -360,6 +361,7 @@ message FileOptions {
optional bool cc_generic_services = 16 [default=false]; optional bool cc_generic_services = 16 [default=false];
optional bool java_generic_services = 17 [default=false]; optional bool java_generic_services = 17 [default=false];
optional bool py_generic_services = 18 [default=false]; optional bool py_generic_services = 18 [default=false];
optional bool php_generic_services = 19 [default=false];
// Is this file deprecated? // Is this file deprecated?
// Depending on the target platform, this can emit Deprecated annotations // Depending on the target platform, this can emit Deprecated annotations
@ -379,6 +381,21 @@ message FileOptions {
// Namespace for generated classes; defaults to the package. // Namespace for generated classes; defaults to the package.
optional string csharp_namespace = 37; optional string csharp_namespace = 37;
// By default Swift generators will take the proto package and CamelCase it
// replacing '.' with underscore and use that to prefix the types/symbols
// defined. When this options is provided, they will use this value instead
// to prefix the types/symbols defined.
optional string swift_prefix = 39;
// Sets the php class prefix which is prepended to all php generated classes
// from this .proto. Default is empty.
optional string php_class_prefix = 40;
// Use this option to change the namespace of php generated classes. Default
// is empty. When this option is empty, the package name will be used for
// determining the namespace.
optional string php_namespace = 41;
// The parser stores options it doesn't recognize here. See above. // The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999; repeated UninterpretedOption uninterpreted_option = 999;
@ -443,6 +460,9 @@ message MessageOptions {
// parser. // parser.
optional bool map_entry = 7; optional bool map_entry = 7;
//reserved 8; // javalite_serializable
//reserved 9; // javanano_as_lite
// The parser stores options it doesn't recognize here. See above. // The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999; repeated UninterpretedOption uninterpreted_option = 999;
@ -471,16 +491,17 @@ message FieldOptions {
// false will avoid using packed encoding. // false will avoid using packed encoding.
optional bool packed = 2; optional bool packed = 2;
// The jstype option determines the JavaScript type used for values of the // The jstype option determines the JavaScript type used for values of the
// field. The option is permitted only for 64 bit integral and fixed types // field. The option is permitted only for 64 bit integral and fixed types
// (int64, uint64, sint64, fixed64, sfixed64). By default these types are // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
// represented as JavaScript strings. This avoids loss of precision that can // is represented as JavaScript string, which avoids loss of precision that
// happen when a large value is converted to a floating point JavaScript // can happen when a large value is converted to a floating point JavaScript.
// numbers. Specifying JS_NUMBER for the jstype causes the generated // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
// JavaScript code to use the JavaScript "number" type instead of strings. // use the JavaScript "number" type. The behavior of the default option
// This option is an enum to permit additional types to be added, // JS_NORMAL is implementation dependent.
// e.g. goog.math.Integer. //
// This option is an enum to permit additional types to be added, e.g.
// goog.math.Integer.
optional JSType jstype = 6 [default = JS_NORMAL]; optional JSType jstype = 6 [default = JS_NORMAL];
enum JSType { enum JSType {
// Use the default type. // Use the default type.
@ -512,7 +533,7 @@ message FieldOptions {
// //
// //
// Note that implementations may choose not to check required fields within // Note that implementations may choose not to check required fields within
// a lazy sub-message. That is, calling IsInitialized() on the outher message // a lazy sub-message. That is, calling IsInitialized() on the outer message
// may return true even if the inner message has missing required fields. // may return true even if the inner message has missing required fields.
// This is necessary because otherwise the inner message would have to be // This is necessary because otherwise the inner message would have to be
// parsed in order to perform the check, defeating the purpose of lazy // parsed in order to perform the check, defeating the purpose of lazy
@ -538,6 +559,8 @@ message FieldOptions {
// Clients can define custom options in extensions of this message. See above. // Clients can define custom options in extensions of this message. See above.
extensions 1000 to max; extensions 1000 to max;
//reserved 4; // removed jtype
} }
message OneofOptions { message OneofOptions {
@ -560,6 +583,8 @@ message EnumOptions {
// is a formalization for deprecating enums. // is a formalization for deprecating enums.
optional bool deprecated = 3 [default=false]; optional bool deprecated = 3 [default=false];
//reserved 5; // javanano_as_lite
// The parser stores options it doesn't recognize here. See above. // The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999; repeated UninterpretedOption uninterpreted_option = 999;
@ -614,6 +639,17 @@ message MethodOptions {
// this is a formalization for deprecating methods. // this is a formalization for deprecating methods.
optional bool deprecated = 33 [default=false]; optional bool deprecated = 33 [default=false];
// Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
// or neither? HTTP based RPC implementation may choose GET verb for safe
// methods, and PUT verb for idempotent methods instead of the default POST.
enum IdempotencyLevel {
IDEMPOTENCY_UNKNOWN = 0;
NO_SIDE_EFFECTS = 1; // implies idempotent
IDEMPOTENT = 2; // idempotent, but may have side effects
}
optional IdempotencyLevel idempotency_level =
34 [default=IDEMPOTENCY_UNKNOWN];
// The parser stores options it doesn't recognize here. See above. // The parser stores options it doesn't recognize here. See above.
repeated UninterpretedOption uninterpreted_option = 999; repeated UninterpretedOption uninterpreted_option = 999;

View File

@ -33,11 +33,11 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "types"; option go_package = "types";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "DurationProto"; option java_outer_classname = "DurationProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A Duration represents a signed, fixed-length span of time represented // A Duration represents a signed, fixed-length span of time represented
@ -47,6 +47,8 @@ option objc_class_prefix = "GPB";
// two Timestamp values is a Duration and it can be added or subtracted // two Timestamp values is a Duration and it can be added or subtracted
// from a Timestamp. Range is approximately +-10,000 years. // from a Timestamp. Range is approximately +-10,000 years.
// //
// # Examples
//
// Example 1: Compute Duration from two Timestamps in pseudo code. // Example 1: Compute Duration from two Timestamps in pseudo code.
// //
// Timestamp start = ...; // Timestamp start = ...;
@ -81,11 +83,28 @@ option objc_class_prefix = "GPB";
// end.nanos -= 1000000000; // end.nanos -= 1000000000;
// } // }
// //
// Example 3: Compute Duration from datetime.timedelta in Python.
//
// td = datetime.timedelta(days=3, minutes=10)
// duration = Duration()
// duration.FromTimedelta(td)
//
// # JSON Mapping
//
// In JSON format, the Duration type is encoded as a string rather than an
// object, where the string ends in the suffix "s" (indicating seconds) and
// is preceded by the number of seconds, with nanoseconds expressed as
// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
// microsecond should be expressed in JSON format as "3.000001s".
//
// //
message Duration { message Duration {
// Signed seconds of the span of time. Must be from -315,576,000,000 // Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. // to +315,576,000,000 inclusive. Note: these bounds are computed from:
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
int64 seconds = 1; int64 seconds = 1;
// Signed fractions of a second at nanosecond resolution of the span // Signed fractions of a second at nanosecond resolution of the span

View File

@ -37,7 +37,6 @@ option go_package = "types";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "EmptyProto"; option java_outer_classname = "EmptyProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
option cc_enable_arenas = true; option cc_enable_arenas = true;

View File

@ -32,12 +32,12 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option go_package = "types"; option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "FieldMaskProto"; option java_outer_classname = "FieldMaskProto";
option java_multiple_files = true; option java_multiple_files = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
option java_generate_equals_and_hash = true; option go_package = "types";
// `FieldMask` represents a set of symbolic field paths, for example: // `FieldMask` represents a set of symbolic field paths, for example:
// //
@ -82,7 +82,7 @@ option java_generate_equals_and_hash = true;
// } // }
// //
// A repeated field is not allowed except at the last position of a // A repeated field is not allowed except at the last position of a
// field mask. // paths string.
// //
// If a FieldMask object is not present in a get operation, the // If a FieldMask object is not present in a get operation, the
// operation applies to all fields (as if a FieldMask of all fields // operation applies to all fields (as if a FieldMask of all fields
@ -109,8 +109,8 @@ option java_generate_equals_and_hash = true;
// //
// If a repeated field is specified for an update operation, the existing // If a repeated field is specified for an update operation, the existing
// repeated values in the target resource will be overwritten by the new values. // repeated values in the target resource will be overwritten by the new values.
// Note that a repeated field is only allowed in the last position of a field // Note that a repeated field is only allowed in the last position of a `paths`
// mask. // string.
// //
// If a sub-message is specified in the last position of the field mask for an // If a sub-message is specified in the last position of the field mask for an
// update operation, then the existing sub-message in the target resource is // update operation, then the existing sub-message in the target resource is

View File

@ -33,11 +33,11 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "types"; option go_package = "types";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "StructProto"; option java_outer_classname = "StructProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";

View File

@ -38,7 +38,6 @@ option go_package = "types";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "TimestampProto"; option java_outer_classname = "TimestampProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A Timestamp represents a point in time independent of any time zone // A Timestamp represents a point in time independent of any time zone
@ -53,6 +52,8 @@ option objc_class_prefix = "GPB";
// and from RFC 3339 date strings. // and from RFC 3339 date strings.
// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
// //
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`. // Example 1: Compute Timestamp from POSIX `time()`.
// //
// Timestamp timestamp; // Timestamp timestamp;
@ -90,16 +91,37 @@ option objc_class_prefix = "GPB";
// //
// Example 5: Compute Timestamp from current time in Python. // Example 5: Compute Timestamp from current time in Python.
// //
// now = time.time() // timestamp = Timestamp()
// seconds = int(now) // timestamp.GetCurrentTime()
// nanos = int((now - seconds) * 10**9) //
// timestamp = Timestamp(seconds=seconds, nanos=nanos) // # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required, though only UTC (as indicated by "Z") is presently supported.
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
// to obtain a formatter capable of generating timestamps in this format.
// //
// //
message Timestamp { message Timestamp {
// Represents seconds of UTC time since Unix epoch // Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive. // 9999-12-31T23:59:59Z inclusive.
int64 seconds = 1; int64 seconds = 1;

View File

@ -43,7 +43,6 @@ option go_package = "types";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "WrappersProto"; option java_outer_classname = "WrappersProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// Wrapper message for `double`. // Wrapper message for `double`.