本文整理汇总了Golang中code/google/com/p/gogoprotobuf/proto.Int64函数的典型用法代码示例。如果您正苦于以下问题:Golang Int64函数的具体用法?Golang Int64怎么用?Golang Int64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Int64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: startAppWithInstancesAndErrors
func startAppWithInstancesAndErrors(t *testing.T, app cf.Application, instances [][]cf.ApplicationInstance, errorCodes []string) (ui *testterm.FakeUI, appRepo *testapi.FakeApplicationRepository, reqFactory *testreq.FakeReqFactory) {
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
config := &configuration.Configuration{
Space: cf.Space{Name: "my-space"},
Organization: cf.Organization{Name: "my-org"},
AccessToken: token,
ApplicationStartTimeout: 2,
}
appRepo = &testapi.FakeApplicationRepository{
FindByNameApp: app,
GetInstancesResponses: instances,
GetInstancesErrorCodes: errorCodes,
}
currentTime := time.Now()
messageType := logmessage.LogMessage_ERR
sourceType := logmessage.LogMessage_DEA
logMessage1 := logmessage.LogMessage{
Message: []byte("Log Line 1"),
AppId: proto.String(app.Guid),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
logMessage2 := logmessage.LogMessage{
Message: []byte("Log Line 2"),
AppId: proto.String(app.Guid),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
logRepo := &testapi.FakeLogsRepository{
TailLogMessages: []logmessage.LogMessage{
logMessage1,
logMessage2,
},
}
args := []string{"my-app"}
reqFactory = &testreq.FakeReqFactory{Application: app}
ui = callStart(args, config, reqFactory, appRepo, logRepo)
return
}
开发者ID:jalateras,项目名称:cli,代码行数:50,代码来源:start_test.go
示例2: TestLogsTailsTheAppLogs
func TestLogsTailsTheAppLogs(t *testing.T) {
app := cf.Application{Name: "my-app", Guid: "my-app-guid"}
currentTime := time.Now()
messageType := logmessage.LogMessage_ERR
deaSourceType := logmessage.LogMessage_DEA
deaSourceId := "42"
deaLogMessage := logmessage.LogMessage{
Message: []byte("Log Line 1"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &deaSourceType,
SourceId: &deaSourceId,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
logs := []logmessage.LogMessage{deaLogMessage}
reqFactory, logsRepo := getLogsDependencies()
reqFactory.Application = app
logsRepo.TailLogMessages = logs
ui := callLogs(t, []string{"my-app"}, reqFactory, logsRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, app, logsRepo.AppLogged)
assert.Equal(t, len(ui.Outputs), 2)
assert.Contains(t, ui.Outputs[0], "Connected, tailing logs for app")
assert.Contains(t, ui.Outputs[0], "my-app")
assert.Contains(t, ui.Outputs[0], "my-org")
assert.Contains(t, ui.Outputs[0], "my-space")
assert.Contains(t, ui.Outputs[0], "my-user")
assert.Contains(t, ui.Outputs[1], "Log Line 1")
}
开发者ID:jalateras,项目名称:cli,代码行数:34,代码来源:logs_test.go
示例3: isAuthorized
func (proxy *Proxy) isAuthorized(appId, authToken string, clientAddress string) (bool, *logmessage.LogMessage) {
newLogMessage := func(message []byte) *logmessage.LogMessage {
currentTime := time.Now()
messageType := logmessage.LogMessage_ERR
return &logmessage.LogMessage{
Message: message,
AppId: proto.String(appId),
MessageType: &messageType,
SourceName: proto.String("LGR"),
Timestamp: proto.Int64(currentTime.UnixNano()),
}
}
if appId == "" {
message := fmt.Sprintf("HttpServer: Did not accept sink connection with invalid app id: %s.", clientAddress)
proxy.logger.Warn(message)
return false, newLogMessage([]byte("Error: Invalid target"))
}
if authToken == "" {
message := fmt.Sprintf("HttpServer: Did not accept sink connection from %s without authorization.", clientAddress)
proxy.logger.Warnf(message)
return false, newLogMessage([]byte("Error: Authorization not provided"))
}
if !proxy.authorize(authToken, appId, proxy.logger) {
message := fmt.Sprintf("HttpServer: Auth token [%s] not authorized to access appId [%s].", authToken, appId)
proxy.logger.Warn(message)
return false, newLogMessage([]byte("Error: Invalid authorization"))
}
return true, nil
}
开发者ID:nkuacac,项目名称:loggregator,代码行数:34,代码来源:output_proxy.go
示例4: NewHttpStop
func NewHttpStop(req *http.Request, statusCode int, contentLength int64, peerType events.PeerType, requestId *uuid.UUID) *events.HttpStop {
httpStop := &events.HttpStop{
Timestamp: proto.Int64(time.Now().UnixNano()),
Uri: proto.String(fmt.Sprintf("%s%s", req.Host, req.URL.Path)),
RequestId: NewUUID(requestId),
PeerType: &peerType,
StatusCode: proto.Int(statusCode),
ContentLength: proto.Int64(contentLength),
}
if applicationId, err := uuid.ParseHex(req.Header.Get("X-CF-ApplicationID")); err == nil {
httpStop.ApplicationId = NewUUID(applicationId)
}
return httpStop
}
开发者ID:KeyOfSpectator,项目名称:gorouter,代码行数:16,代码来源:factories.go
示例5: NewHttpStart
func NewHttpStart(req *http.Request, peerType events.PeerType, requestId *uuid.UUID) *events.HttpStart {
httpStart := &events.HttpStart{
Timestamp: proto.Int64(time.Now().UnixNano()),
RequestId: NewUUID(requestId),
PeerType: &peerType,
Method: events.HttpStart_Method(events.HttpStart_Method_value[req.Method]).Enum(),
Uri: proto.String(fmt.Sprintf("%s%s", req.Host, req.URL.Path)),
RemoteAddress: proto.String(req.RemoteAddr),
UserAgent: proto.String(req.UserAgent()),
}
if applicationId, err := uuid.ParseHex(req.Header.Get("X-CF-ApplicationID")); err == nil {
httpStart.ApplicationId = NewUUID(applicationId)
}
if instanceIndex, err := strconv.Atoi(req.Header.Get("X-CF-InstanceIndex")); err == nil {
httpStart.InstanceIndex = proto.Int(instanceIndex)
}
if instanceId := req.Header.Get("X-CF-InstanceID"); instanceId != "" {
httpStart.InstanceId = &instanceId
}
return httpStart
}
开发者ID:KeyOfSpectator,项目名称:gorouter,代码行数:25,代码来源:factories.go
示例6: Increment
// Increment fetches the value for key, and assuming the value is an
// "integer" type, increments it by inc and stores the new value. The
// newly incremented value is returned.
func (mvcc *MVCC) Increment(key Key, timestamp proto.Timestamp, txn *proto.Transaction, inc int64) (int64, error) {
// Handle check for non-existence of key. In order to detect
// the potential write intent by another concurrent transaction
// with a newer timestamp, we need to use the max timestamp
// while reading.
value, err := mvcc.Get(key, proto.MaxTimestamp, txn)
if err != nil {
return 0, err
}
var int64Val int64
// If the value exists, verify it's an integer type not a byte slice.
if value != nil {
if value.Bytes != nil || value.Integer == nil {
return 0, util.Errorf("cannot increment key %q which already has a generic byte value: %+v", key, *value)
}
int64Val = value.GetInteger()
}
// Check for overflow and underflow.
if encoding.WillOverflow(int64Val, inc) {
return 0, util.Errorf("key %q with value %d incremented by %d results in overflow", key, int64Val, inc)
}
if inc == 0 {
return int64Val, nil
}
r := int64Val + inc
value = &proto.Value{Integer: gogoproto.Int64(r)}
value.InitChecksum(key)
return r, mvcc.Put(key, timestamp, *value, txn)
}
开发者ID:embark,项目名称:cockroach,代码行数:36,代码来源:mvcc.go
示例7: TestValueBothBytesAndIntegerSet
func TestValueBothBytesAndIntegerSet(t *testing.T) {
k := []byte("key")
v := Value{Bytes: []byte("a"), Integer: gogoproto.Int64(0)}
if err := v.Verify(k); err == nil {
t.Error("expected error with both byte slice and integer fields set")
}
}
开发者ID:bdotdub,项目名称:cockroach,代码行数:7,代码来源:data_test.go
示例8: ExampleCompile
func ExampleCompile() {
a := &test.NinOptNative{
Field4: proto.Int64(1234),
Field7: proto.Int32(123),
}
fp1, err := fieldpath.NewInt64Path("test", "NinOptNative", test.ThetestDescription(), "Field4")
if err != nil {
panic(err)
}
fp2, err := fieldpath.NewSint32Path("test", "NinOptNative", test.ThetestDescription(), "Field7")
if err != nil {
panic(err)
}
buf, err := proto.Marshal(a)
if err != nil {
panic(err)
}
u1 := fieldpath.NewInt64Unmarshaler(fp1, &handler64{})
u2 := fieldpath.NewSint32Unmarshaler(fp2, &handler32{})
c := fieldpath.Compile(u1, u2)
err = c.Unmarshal(buf)
if err != nil {
panic(err)
}
// Output:
// 1234
// 123
}
开发者ID:raceli,项目名称:gogoprotobuf,代码行数:28,代码来源:example-compiled_test.go
示例9: TestMVCCPutWithBadValue
func TestMVCCPutWithBadValue(t *testing.T) {
mvcc := createTestMVCC(t)
badValue := proto.Value{Bytes: []byte("a"), Integer: gogoproto.Int64(1)}
err := mvcc.Put(testKey1, makeTS(0, 0), badValue, nil)
if err == nil {
t.Fatal("expected an error putting a value with both byte slice and integer components")
}
}
开发者ID:embark,项目名称:cockroach,代码行数:8,代码来源:mvcc_test.go
示例10: newTestMessage
func newTestMessage() *pb.MyMessage {
msg := &pb.MyMessage{
Count: proto.Int32(42),
Name: proto.String("Dave"),
Quote: proto.String(`"I didn't want to go."`),
Pet: []string{"bunny", "kitty", "horsey"},
Inner: &pb.InnerMessage{
Host: proto.String("footrest.syd"),
Port: proto.Int32(7001),
Connected: proto.Bool(true),
},
Others: []*pb.OtherMessage{
{
Key: proto.Int64(0xdeadbeef),
Value: []byte{1, 65, 7, 12},
},
{
Weight: proto.Float32(6.022),
Inner: &pb.InnerMessage{
Host: proto.String("lesha.mtv"),
Port: proto.Int32(8002),
},
},
},
Bikeshed: pb.MyMessage_BLUE.Enum(),
Somegroup: &pb.MyMessage_SomeGroup{
GroupField: proto.Int32(8),
},
// One normally wouldn't do this.
// This is an undeclared tag 13, as a varint (wire type 0) with value 4.
XXX_unrecognized: []byte{13<<3 | 0, 4},
}
ext := &pb.Ext{
Data: proto.String("Big gobs for big rats"),
}
if err := proto.SetExtension(msg, pb.E_Ext_More, ext); err != nil {
panic(err)
}
greetings := []string{"adg", "easy", "cow"}
if err := proto.SetExtension(msg, pb.E_Greeting, greetings); err != nil {
panic(err)
}
// Add an unknown extension. We marshal a pb.Ext, and fake the ID.
b, err := proto.Marshal(&pb.Ext{Data: proto.String("3G skiing")})
if err != nil {
panic(err)
}
b = append(proto.EncodeVarint(201<<3|proto.WireBytes), b...)
proto.SetRawExtension(msg, 201, b)
// Extensions can be plain fields, too, so let's test that.
b = append(proto.EncodeVarint(202<<3|proto.WireVarint), 19)
proto.SetRawExtension(msg, 202, b)
return msg
}
开发者ID:hail100,项目名称:cli,代码行数:57,代码来源:text_test.go
示例11: TestLogsOutputsRecentLogs
func TestLogsOutputsRecentLogs(t *testing.T) {
app := cf.Application{Name: "my-app", Guid: "my-app-guid"}
currentTime := time.Now()
messageType := logmessage.LogMessage_ERR
sourceType := logmessage.LogMessage_DEA
logMessage1 := logmessage.LogMessage{
Message: []byte("Log Line 1"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
logMessage2 := logmessage.LogMessage{
Message: []byte("Log Line 2"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
recentLogs := []logmessage.LogMessage{
logMessage1,
logMessage2,
}
reqFactory, logsRepo := getLogsDependencies()
reqFactory.Application = app
logsRepo.RecentLogs = recentLogs
ui := callLogs(t, []string{"--recent", "my-app"}, reqFactory, logsRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, app, logsRepo.AppLogged)
assert.Equal(t, len(ui.Outputs), 3)
assert.Contains(t, ui.Outputs[0], "Connected, dumping recent logs for app")
assert.Contains(t, ui.Outputs[0], "my-app")
assert.Contains(t, ui.Outputs[0], "my-org")
assert.Contains(t, ui.Outputs[0], "my-space")
assert.Contains(t, ui.Outputs[0], "my-user")
assert.Contains(t, ui.Outputs[1], "Log Line 1")
assert.Contains(t, ui.Outputs[2], "Log Line 2")
}
开发者ID:jalateras,项目名称:cli,代码行数:44,代码来源:logs_test.go
示例12: makeLogMessage
func makeLogMessage(appId, message, sourceType, sourceInstance string, messageType events.LogMessage_MessageType) *events.LogMessage {
return &events.LogMessage{
Message: []byte(message),
AppId: proto.String(appId),
MessageType: &messageType,
SourceType: &sourceType,
SourceInstance: &sourceInstance,
Timestamp: proto.Int64(time.Now().UnixNano()),
}
}
开发者ID:johannespetzold,项目名称:gorouter,代码行数:10,代码来源:log_sender.go
示例13: listen
func (ls *loggingStream) listen() {
newLogMessage := func(message []byte) *logmessage.LogMessage {
currentTime := time.Now()
sourceType := logmessage.LogMessage_WARDEN_CONTAINER
return &logmessage.LogMessage{
Message: message,
AppId: proto.String(ls.inst.applicationId),
DrainUrls: ls.inst.drainUrls,
MessageType: &ls.messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
}
socket := func(messageType logmessage.LogMessage_MessageType) (net.Conn, error) {
return net.Dial("unix", filepath.Join(ls.inst.identifier(), socketName(messageType)))
}
go func() {
connection, err := socket(ls.messageType)
if err != nil {
ls.logger.Errorf("Error while dialing into socket %s, %s", ls.messageType, err)
return
}
defer func() {
connection.Close()
ls.logger.Infof("Stopped reading from socket %s", ls.messageType)
}()
buffer := make([]byte, bufferSize)
for {
readCount, err := connection.Read(buffer)
if readCount == 0 && err != nil {
ls.logger.Infof("Error while reading from socket %s, %s", ls.messageType, err)
break
}
ls.logger.Debugf("Read %d bytes from instance socket %s", readCount, ls.messageType)
atomic.AddUint64(ls.messagesReceived, 1)
atomic.AddUint64(ls.bytesReceived, uint64(readCount))
ls.loggregatorClient.IncLogStreamRawByteCount(uint64(readCount))
data, err := proto.Marshal(newLogMessage(buffer[0:readCount]))
if err != nil {
ls.logger.Errorf("Error marshalling log message: %s", err)
}
ls.loggregatorClient.IncLogStreamPbByteCount(uint64(len(data)))
ls.loggregatorClient.Send(data)
ls.logger.Debugf("Sent %d bytes to loggregator client", readCount)
runtime.Gosched()
}
}()
}
开发者ID:narayana1208,项目名称:loggregator,代码行数:55,代码来源:logging_stream.go
示例14: TestLogsTailsTheAppLogs
func TestLogsTailsTheAppLogs(t *testing.T) {
app := cf.Application{Name: "my-app", Guid: "my-app-guid"}
///////////////
currentTime := time.Now()
messageType := logmessage.LogMessage_ERR
sourceType := logmessage.LogMessage_DEA
logMessage1 := &logmessage.LogMessage{
Message: []byte("Log Line 1"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
logMessage2 := &logmessage.LogMessage{
Message: []byte("Log Line 2"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
/////////////////
logs := []*logmessage.LogMessage{
logMessage1,
logMessage2,
}
reqFactory, logsRepo := getDefaultLogsDependencies()
reqFactory.Application = app
logsRepo.TailLogMessages = logs
ui := callLogs([]string{"my-app"}, reqFactory, logsRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, app, logsRepo.AppLogged)
assert.Equal(t, len(ui.Outputs), 3)
assert.Contains(t, ui.Outputs[0], "Connected")
assert.Contains(t, ui.Outputs[1], "Log Line 1")
assert.Contains(t, ui.Outputs[2], "Log Line 2")
}
开发者ID:jbayer,项目名称:cli,代码行数:42,代码来源:logs_test.go
示例15: TestRecentLogsWithAppName
func TestRecentLogsWithAppName(t *testing.T) {
config := &configuration.Configuration{}
app := cf.Application{Name: "my-app", Guid: "my-app-guid"}
appRepo := &testhelpers.FakeApplicationRepository{AppByName: app}
///////////////
currentTime := time.Now()
messageType := logmessage.LogMessage_ERR
sourceType := logmessage.LogMessage_DEA
logMessage1 := &logmessage.LogMessage{
Message: []byte("Log Line 1"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
logMessage2 := &logmessage.LogMessage{
Message: []byte("Log Line 2"),
AppId: proto.String("my-app"),
MessageType: &messageType,
SourceType: &sourceType,
Timestamp: proto.Int64(currentTime.UnixNano()),
}
/////////////////
recentLogs := []*logmessage.LogMessage{
logMessage1,
logMessage2,
}
logsRepo := &testhelpers.FakeLogsRepository{RecentLogs: recentLogs}
reqFactory := &testhelpers.FakeReqFactory{Application: app}
ui := callRecentLogs([]string{"my-app"}, config, reqFactory, appRepo, logsRepo)
assert.Equal(t, reqFactory.ApplicationName, "my-app")
assert.Equal(t, app, logsRepo.AppLogged)
assert.Equal(t, len(ui.Outputs), 2)
assert.Contains(t, ui.Outputs[0], "Log Line 1")
assert.Contains(t, ui.Outputs[1], "Log Line 2")
}
开发者ID:jbayer,项目名称:cli,代码行数:42,代码来源:recent_logs_test.go
示例16: NewNoaaLogMessage
func NewNoaaLogMessage(msgText, appGuid, sourceName string, timestamp time.Time) *events.LogMessage {
messageType := events.LogMessage_ERR
return &events.LogMessage{
Message: []byte(msgText),
AppId: proto.String(appGuid),
MessageType: &messageType,
SourceType: proto.String(sourceName),
Timestamp: proto.Int64(timestamp.UnixNano()),
}
}
开发者ID:raghulsid,项目名称:cli,代码行数:11,代码来源:log_messages.go
示例17: makeLogMessage
func makeLogMessage(message string, timestamp int64) *logmessage.LogMessage {
messageType := logmessage.LogMessage_OUT
sourceName := "DEA"
return &logmessage.LogMessage{
Message: []byte(message),
AppId: proto.String("my-app-guid"),
MessageType: &messageType,
SourceName: &sourceName,
Timestamp: proto.Int64(timestamp),
}
}
开发者ID:hail100,项目名称:cli,代码行数:11,代码来源:logs_test.go
示例18: TestValueChecksumWithInteger
func TestValueChecksumWithInteger(t *testing.T) {
k := []byte("key")
testValues := []int64{0, 1, -1, math.MinInt64, math.MaxInt64}
for _, i := range testValues {
v := Value{Integer: gogoproto.Int64(i)}
v.InitChecksum(k)
if err := v.Verify(k); err != nil {
t.Error(err)
}
// Try a different key; should fail.
if err := v.Verify([]byte("key2")); err == nil {
t.Error("expected checksum verification failure on different key")
}
// Mess with value.
v.Integer = gogoproto.Int64(i + 1)
if err := v.Verify(k); err == nil {
t.Error("expected checksum verification failure on different value")
}
}
}
开发者ID:bdotdub,项目名称:cockroach,代码行数:20,代码来源:data_test.go
示例19: newLogMessage
func (e *LoggregatorEmitter) newLogMessage(appId, message string, mt events.LogMessage_MessageType) *events.LogMessage {
currentTime := time.Now()
return &events.LogMessage{
Message: []byte(message),
AppId: proto.String(appId),
MessageType: &mt,
SourceInstance: &e.sId,
Timestamp: proto.Int64(currentTime.UnixNano()),
SourceType: &e.sn,
}
}
开发者ID:johannespetzold,项目名称:gorouter,代码行数:12,代码来源:emit.go
示例20: generateLogMessage
func generateLogMessage(messageString string, appId *string) *logmessage.LogMessage {
messageType := logmessage.LogMessage_ERR
currentTime := time.Now()
logMessage := &logmessage.LogMessage{
Message: []byte(messageString),
AppId: appId,
MessageType: &messageType,
SourceName: proto.String("LGR"),
Timestamp: proto.Int64(currentTime.UnixNano()),
}
return logMessage
}
开发者ID:pxie,项目名称:loggregator,代码行数:13,代码来源:truncating_buffer.go
注:本文中的code/google/com/p/gogoprotobuf/proto.Int64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论