| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 // +build darwin dragonfly freebsd linux netbsd openbsd | |
| 6 | |
| 7 package main | |
| 8 | |
| 9 import ( | |
| 10 "errors" | |
| 11 "fmt" | |
| 12 | |
| 13 "github.com/luci/luci-go/client/internal/logdog/butler/streamserver" | |
| 14 "golang.org/x/net/context" | |
| 15 ) | |
| 16 | |
| 17 const ( | |
| 18 // An example stream server URI. | |
| 19 exampleStreamServerURI = streamServerURI("unix:/var/run/butler.sock") | |
| 20 ) | |
| 21 | |
| 22 type streamServerURI string | |
| 23 | |
| 24 func (u streamServerURI) Parse() (string, error) { | |
| 25 typ, value := parseStreamServer(string(u)) | |
| 26 if typ != "unix" { | |
| 27 return "", fmt.Errorf("unsupported URI scheme: [%s]", typ) | |
| 28 } | |
| 29 if value == "" { | |
| 30 return "", errors.New("empty stream server path") | |
| 31 } | |
| 32 return value, nil | |
| 33 } | |
| 34 | |
| 35 // Validates that the URI is correct for Windows. | |
| 36 func (u streamServerURI) Validate() (err error) { | |
| 37 _, err = u.Parse() | |
| 38 return | |
| 39 } | |
| 40 | |
| 41 // Create a POSIX (UNIX named pipe) stream server | |
| 42 func createStreamServer(ctx context.Context, uri streamServerURI) streamserver.S
treamServer { | |
| 43 path, err := uri.Parse() | |
| 44 if err != nil { | |
| 45 panic("Failed to parse stream server URI.") | |
| 46 } | |
| 47 return streamserver.NewNamedPipeServer(ctx, path) | |
| 48 } | |
| OLD | NEW |