Esempio n. 1
0
func main() {
	flag.Parse()
	cerr := make(chan error)
	defer close(cerr)
	go LogError(cerr)

	urls := make(chan string)
	go FeedFromFile(*urlsPath, urls, cerr)

	defaultFetcher := fetcher.DefaultFetcher{}
	fetchInfo := make(chan *fetcher.FetchInfo)
	go fetcher.ScheduleLinearFetch(defaultFetcher, urls, fetchInfo)

	tbl, err := table.Create(table.TableOption{
		BaseDirectory: *tablePath,
		KeepSnapshots: true,
	})
	if err != nil {
		log.Println(err)
		return
	}
	var wg sync.WaitGroup
	wg.Add(1)
	WriteTable(tbl, fetchInfo, &wg)
	wg.Wait()
}
Esempio n. 2
0
func main() {
	flag.Parse()
	var err error
	tbl, err = table.Create(table.TableOption{
		BaseDirectory: *tablePath,
		KeepSnapshots: true,
	})
	if err != nil {
		log.Println(err)
		return
	}
	http.HandleFunc("/", indexHandler)
	http.HandleFunc("/favicon.ico", faviconHandler)
	http.ListenAndServe(*addr, nil)
}
Esempio n. 3
0
// ls prints the list of keys of each path.
func ls(tablePaths []string) {
	for _, tablePath := range tablePaths {
		tbl, err := table.Create(table.TableOption{
			BaseDirectory: tablePath,
			KeepSnapshots: true,
		})
		if err != nil {
			log.Println("Error on path", tablePath, ":", err)
			return
		}
		for key := range tbl.Keys() {
			fmt.Println(string(key))
		}
	}
}
Esempio n. 4
0
// cat prints the value of the key.
func cat(tablePath string, key string) {
	tbl, err := table.Create(table.TableOption{
		BaseDirectory: tablePath,
		KeepSnapshots: true,
	})
	if err != nil {
		log.Println(err)
		return
	}
	value, err := tbl.Get([]byte(key))
	if err != nil {
		log.Println(err)
		return
	}
	fmt.Println(string(value))
}
Esempio n. 5
0
func main() {
	flag.Parse()
	var err error
	wikiTable, err = table.Create(table.TableOption{*dbPath, nil, true})
	if err != nil {
		log.Println(err)
		return
	}
	http.HandleFunc("/", viewHandler)
	http.HandleFunc("/view/", viewHandler)
	http.HandleFunc("/edit/", viewHandler)
	http.HandleFunc("/modify/", modifyHandler)
	log.Printf("Server being ready: %s\n", *addr)
	if err := http.ListenAndServe(*addr, nil); err != nil {
		log.Println(err)
	}
}